How to update JLabel in Swing?
Posted
by Roman
on Stack Overflow
See other posts from Stack Overflow
or by Roman
Published on 2010-03-19T12:23:18Z
Indexed on
2010/03/19
12:41 UTC
Read the original article
Hit count: 164
I am trying to use Swing Timer and I wanted to start from a very simple program. I have a window with text: "You have n seconds", where n changes from 10 to 0 every second.
I know how to generate a window with text. And I understand how Timer works (it starts an action periodically). But I cannot figure out how to combing this two things. Should I use that: JLabel label = new JLabel(myMessage);
and then with timer I need to update the "myMessage" variable?
But I think I need to "force" my window to "update" itself (to display a new value stored in "myMessage").
© Stack Overflow or respective owner