简体   繁体   中英

How to change visibility of ALL items in a JFrame at once?

I wonder whether there is a possiblity to change the visibility of more than one item (textbox, button, chart ...) in a JFrame in one simple(?) command.

Thanks for answers and ideas!

(Hiding the whole JFrame is no option ;))

Place all into a panel and hide/show the panel. That should propagate to all child components as well

You could use a CardLayout , as shown here .

游戏画面高分视图

Obviously, one of the two panels shown in the demo would have no components.

Place components into Collection, then you can use simple iteration to set/clear any flags. You need to create a Collection and add objects to it, but this allows to separate visibility control from the component layout.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM