[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Problem in getting "bounds" property in Introspection

Posted on 2003-12-10
12
Medium Priority
?
282 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 does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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 300 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 450 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
In this post we will learn different types of Android Layout and some basics of an Android App.
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses

649 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