Search for a Java layoutmanager that hides elements if space becomes short

I am looking for a Java layoutmanager that can automatically hide the (less important) elements that I define if the user reduces the size of the window.

For example, the icon in the label bar and JTextField, which exists only to visually improve the form. If the user resizes the window to the minimum size, the icon should disappear in order to provide the remaining space for the label and text field.

Hi

+4
source share
3 answers

If there is not enough space, GBL will switch from preferredSize to minimumSize, so if you set a very small minimum size for less important components, GBL will work for you. You can also add the Listener component and simply rebuild the GUI by manually removing the components, or simply switch to a different view.

You could even create a β€œmini” view button in the GUI that would automatically resize to the smallest possible size, but retain a reasonable size instead of having users face their own breaches in a carefully thought-out design :)

+2
source

Well, from my recollections, it seems to me that GridBagLayout will also hide less important elements when the size decreases.

0
source

You can create your own LayoutManager (which, of course, extends one of the existing layout managers). It's pretty funny, I had such an experience when it developed with a swing.

0
source

Source: https://habr.com/ru/post/1301478/


All Articles