Refresh elements of GUI in java
Swing is event driven. All components work through the MVC pattern. You don't need to explicitly repaint it by hiding/showing in order to update it's representation on the screen.
You just do yourLabel.setText("your new text")
and the new text will appear on the label.
Keep in mind that most GUI-updates (the setText
is an exception) needs to be performed on the EDT, so use SwingUtilities.invokeLater
etc if you're update is triggered by, say, a network message.
If you do structural changes to the GUI you'll have to revalidate()
/repaint()
though.