I am trying to update a JLabel by using the setText()
method, but I can\'t redraw JLabel. Do I have to use the repaint()
method to do that?
I'm a bit stumped on how the repainting of frames/component works in Java. You can Paint(Graphics g)
, update(Graphics g)
which according to the javadoc just calls paint(g)
. Finally there's also repaint()
...
If none of those seem to work, wouldn't it just be easier to create the label only at the line where you are currently trying to set the text?
Edit: there is also the option of using an ineditable textArea. Not only can it display the standard newline character, but you can put it in a jScrollPane, which is handy when you have lots of files in the log, and you don't need to repaint text components to display updated text. The bonus is magnificent imo...