dcsimg
Resizing JPanel within JTree
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Ninel_Karamaneva
Posted On:   Thursday, May 26, 2005 11:14 AM

I have a JTree whose elements are JPanels with several JButtons laid out horizontally. When I create a JPanel element I don't give it any size restrictions, so it sizes itself based on the dimensions of the buttons that I add to it. My problem is that one of the buttons needs to be made invisible under certain conditions and visible under others. When I first construct the JTree, this button is invisible by default. When I make it visible, its JPanel parent expands in order to accomodate the newly visible button. However, when I make the button invisible again, the JPanel doesn't contract back to its original size. Using setSize(), setPreferredSize(), setMaximumSize() etc. on the JPanel didn't seem to help. Is there something equivalent to the    More>>

I have a JTree whose elements are JPanels with several JButtons laid out horizontally. When I create a JPanel element I don't give it any size restrictions, so it sizes itself based on the dimensions of the buttons that I add to it. My problem is that one of the buttons needs to be made invisible under certain conditions and visible under others.


When I first construct the JTree, this button is invisible by default. When I make it visible, its JPanel parent expands in order to accomodate the newly visible button. However, when I make the button invisible again, the JPanel doesn't contract back to its original size. Using setSize(), setPreferredSize(), setMaximumSize() etc. on the JPanel didn't seem to help. Is there something equivalent to the pack() method in the Window class that can be applied to JPanel or some other trick I can use to make the JPanel shrink to its original size?


Thanks.

   <<Less
About | Sitemap | Contact