Java GUI better to remove or setVisible(false)?
java, swing, user-interface
Solution
Usually such things depend on the designer's opinion, however it depends what what exactly you're trying to show/hide.
If you want to display a widget after a certain condition/method returns true then just use setVisible(true), this allows you to easily toggle on/off.
If you want to display the widget only once(and not hide it ever again) then just .add it when you need to so that it's displayed(condition/method).
All boils down to preference
Problem
I am coding up a relatively simple GUI application in Java using widgets from the Swing library. What is the common practice for 'conditionally' displaying certain items? Is it to `.setVisible(false)` on things that we want to temporarily hide; or is it to `.add` items as they are needed and then removing them when they are not to be shown any more?