views:

48

answers:

3

Hi,

I'm searching for a Java layoutmanager which is able to automatically hide (less important) elements, defined by me, if the user scales down the window size.

For example an icon in a row of a label and a JTextField, which is only there to visually enhance the form. If the user resizes the window to a minimum size, the icon should disappear to give the remaining space to the label and the textfield.

Regards

A: 

Well, from my memories, it seems to me that a GridBagLayout will also hide less important items when size scales down.

Riduidel
+1  A: 

If there is not enough space GBL will switch from preferredSize to minimumSize so possibly if you set a very small minimumSize for the less important components GBL will work for you. You could also add a componentListener and just rebuild the GUI by manually removing components or just switching into another view.

You could even build a 'mini' view button into the GUI that would automatically resize to smallest possible but maintain a sensible size instead of users having to faff around on their own breaking stuff in your carefully planned design :)

willcodejavaforfood
You're right. Setting minimumSize to (0,0) does the job. Thank You!
WoF
No problems mate
willcodejavaforfood
A: 

You can create your own LayoutManager (which, of course, extends one of existing layout managers). It's rather funny, I had such experience when was developing with swing.

Roman