Hi. I have an app that has fields that are setVisible(false) when my application runs. If the user clicks a certain button, these fields are supposed to appear. My problem is when they appear, they are tiny. I think it is becuase when the app ran, these fields were not visible, so it didn't pack them. I need to know how to be able to recognize these fields, even though they are not visible so my frame is large enough for them when they do appear. I hope this makes sense! Thanks for any help!
Thanks for the reply! I have the set the size of my app. That works. Now the problem I have, is whenever the components are set to "setVisible(false)", Everything shifts so it's centered in the middle. I want all of my other components to stay where they are at!! Is this possibly a GridBagLayout manager issue? If so, what do I need to do to make my components stay where they are at when I set other components' visiblity to false? Any help is greatly appreciated!!
Manfred Leonhardt
Ranch Hand
Joined: Jan 09, 2001
Posts: 1492
posted
0
Hi Jennifer, The problem is indeed GridBagLayout and there is really nothing you can do about this behavior. You have two possible solutions: 1. Show the components but use setEnabled() instead of setVisible. This will at least show the user that those controls are not useable in the current "mode". 2. Use a dummy component, such as an empty frame, to swap with the actual component. Some problems with this approach would be: how to get the size for the actual componet ... My personal choice would be number one because I hate GUIs that have components that appear and disappear. Regards, Manfred.
Jennifer Sohl
Ranch Hand
Joined: Feb 28, 2001
Posts: 455
posted
0
Hi Manfred. I will use setEnabled(false). It works beautifully. However, I was wondering if there was a way to make a whole class not enabled. I have an address class that I am using in my main application and I would like to be able to do a setEnabled on the Address object and have it disable all the fields. Is there any way to do this, or do I have to do the old fashioned way, disabling every field in the Address class one by one? Thanks a bunch!
Manfred Leonhardt
Ranch Hand
Joined: Jan 09, 2001
Posts: 1492
posted
0
Hi Jennifer, Unfortunately, I think you will need to call the method for each component. I can't seem to get anything else to work myself ... Regards, Manfred.