Usually such things depend on the opinion of the designer, however, it depends on what exactly you are trying to show / hide.
If you want to display the widget after a certain condition / method returns true, just use setVisible (true), this allows you to easily turn on / off.
If you want to display the widget only once (and no longer hide it), then just .add when you need it to be displayed (condition / method).
It all depends on preference
source
share