Java repaint not updating

23 Feb

Submit a bug or feature For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples. When you extend a Component (like when you write a Applet), if you want to display it differently than its superclass, you override public void paint(Graphics) .This was first illustrated in Chapter 3, iii) repaint() The repaint() method is sent to a Component when it needs to be repainted.

I can simulate this by making the thread sleep for 3 seconds (see code below).If hiding the panel, or frame by using set Visible and making it visible again updating the GUI.But, I didn't understand why repaint is not updating the GUI? Creating the layout from scratch is an overhead that the creators of AWT probably thought unnecessary during painting, given that painting occurs much more frequently than changes to the UI.JDK 1.1.7A and Swing, on Windows NT In a simple Java application I have a JButton "btn Go" and a JLabel "lbl Status" within a JPanel.When I click the Go button, I want the status label to immediately display the text "Working...", then I want to carry out some time-intensive tasks.