开发者

Searching for a Java layoutmanager which hides elements if space is getting short

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 f开发者_JAVA技巧orm. 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


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 :)


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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜