Solved

Problem in getting "bounds" property in Introspection

Posted on 2003-12-10
12
280 Views
Last Modified: 2012-05-04
Hi all,

I am facing a problem for "bounds" property (i.e. getBounds() and setBounds for Component class). Problem is I am not getting "bounds" property listed in propertydescriptor of a component. And I have to use propertydescriptor to use name of the property to get notified that a particular property is changed. I get notification for all properties except "bounds" property (using PropertyChangeListener). So, Please provide help for solving this problem. I don't get any information regarding this issue on any site. One more thing. Here "bounds" property means "setBounds" and "getBounds" of a component and not Bound and Constraint properties of JavaBeans. Please give any suggestion.

regards,

Sanket.
0
Comment
Question by:SanketDesai
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
  • 3
12 Comments
 
LVL 92

Expert Comment

by:objects
ID: 9918580
Use a ComponentListener to listen for size changes.
0
 
LVL 1

Expert Comment

by:RodionP
ID: 9922541
As far as I understood your question, getBounds returns a Rectangle of the bounds of current component that is drawn on the screen in pixels. please let me know what exactly does it return, I sense some misinterpritation of the data, beacause I always used that fucntion and I never had any problems.
I also think that PropertyChangeListener is not the one you should be using for component size change. ComponentListener should be used, componentResized() in particular
0
 
LVL 1

Author Comment

by:SanketDesai
ID: 9940937
Hi RodionP,
         Thanks for your suggestion. Actually my problem is i want to be notified by propertychangelistener whenever size of a component is changed (i.e. using setbounds or setsize etc..). Simple reason for this is that i want old and new values both for this property. Suggestion for componentlistener can not be used because it just gives me new set of values and not old values. I hope you are getting my problem. As far as I know it is almost impossible to get old and new values both for "bounds". Please give me any suggestions you have. Suggestions and questions are always welcome!.

Thanks,

Sanket.


0
What Is Transaction Monitoring and who needs it?

Synthetic Transaction Monitoring that you need for the day to day, which ensures your business website keeps running optimally, and that there is no downtime to impact your customer experience.

 
LVL 1

Expert Comment

by:RodionP
ID: 9942683
Well, how about you just keep 2 values (variables of type Rectangle would be best I think), one old and one new, on every resize event performe the following:

public void componentResized(ComponentEvent e){
    oldVvalue = newValue
    newValue = this.getSize();
}

simple as that, and at any given moment you will always have 2 copies of the size, which are current size and old size.

That is how animation works, they keep 2 copies of some shape that has to be drawn, and they set the XOR mode for drawing, and in each frame they draw the old value (that overlaps with previously drawn shape and consequently erases it) and draw the new one.
0
 
LVL 92

Assisted Solution

by:objects
objects earned 100 total points
ID: 9944464
> Simple reason for this is that i want old and new values both for this property

if you want the old value then just remember it as suggested by RodionP.
You could even create a ComponentListener that fired a PropertyChangeEvent if you wanted.
0
 
LVL 1

Author Comment

by:SanketDesai
ID: 9947476
Hi RodionP and objects,

         Thank you very much taking keen interest in this problem. I really appreciate your suggestions. But still i am unable to get my solution. Let me explain the whole scenario in detail. I am developing Undo/Redo framework for a product (but I am trying to make it generalized). This product is already in working condition. So, this framework is enhancement. I can't change any already written code. Considering these points, The only way i can be notified about propertychange is propertychangelistener. I can't keep track of both old and new set values for each and every component, because how many components will be added at run time that can't be predicted. Lets hope for solutions. Once again thanks for taking such interest.

Sanket.
0
 
LVL 92

Expert Comment

by:objects
ID: 9947495
Why won't my suggestion above work, ie. use a ComponentChangeListener that fires PropertyChangeEvents.
0
 
LVL 1

Author Comment

by:SanketDesai
ID: 9947525
Hi objects,

           If i incorporate your suggestion in my application, then it would become the soultion of this product only. As in my previous comment i have clearly mentioned that i want to make this framework generalized one. So, once a component is added, all properties of that component should be undone and redone and that is also using propertychangelistener. Let us say NO OTHER OPTION is available for me other than to use propertychangelistener. If you have any suggestions (using propertychagelistener) then please let me know!. Thanks for your comment.

Sanket.
0
 
LVL 92

Expert Comment

by:objects
ID: 9947603
then you cannot do it because Component do not fire PropertyChangeEvent's when they change size.
0
 
LVL 1

Accepted Solution

by:
RodionP earned 150 total points
ID: 9954243
Well, my suggestion would be the following, how all general undo/redo work, every program has a model behind it, some data structure that describes the problem, engine so to speak... (In MS Word this is a document in Windows this is some state of machine at a given moment). So when any changes occur, the model behind changes, and representation of that model will consequently change. So if you want it generalized, keep instances of your engine, or some portions of it depending on the implementation. It is important to understand that GUI is simply a matter of representation and there are many representations of some abstract object, undo/redo functionality should be dependant on the representation. I am probobly getting too general and theoretical, but that is the way I see it, and that is the way how I implement undo/redo in all the applications I have written.

However I cannot help you with propertychangelistener, you have to implement your own listeners and events that in some way incorporate ComponentEvent
0
 
LVL 1

Author Comment

by:SanketDesai
ID: 10171319
Hi both of you,

        Though i have not got exact answer for my problem, i have got some hint for that indeed. Thanks for your reponses!

Sanket.
0
 
LVL 92

Expert Comment

by:objects
ID: 10171344
0

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question