I have a Java Swing user interface that does not update / repaint as I thought. The application sends an XMPP message and receives a response to another stream. This response is processed, and the user interface is updated to reflect the information contained in the message.
When a response is received, I update the JPanel component using
javax.swing.SwingUtilities.invokeLater(new Runnable() { public void run() { } });
It has been quite a while since I developed it in Java, but based on my online research on invokeLater, queues are started to run in a GUI thread. However, my GUI is not updated until I do something else in the application that causes the redraw - for example, resizing the window. What am I missing? After the panel update logic, I tried various combinations of invalidate () and repaint (), but the result is the same - the GUI is not updated until, say, I resize the window.
EDIT: When I talk about updating the panel, I, in particular, do removeAll (), and then add some JLabels.
java user-interface swing
Matt
source share