Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4521474

Panel does not repaint itself on Windows only.



    • Type: Bug
    • Status: Closed
    • Priority: P3
    • Resolution: Duplicate
    • Affects Version/s: 1.4.0
    • Fix Version/s: None
    • Component/s: client-libs
    • Labels:
    • Subcomponent:
    • CPU:
    • OS:


      Here is a simple code:
      import java.awt.*;
      import java.awt.event.*;

      public class SimpleTest extends Panel implements ActionListener

          Button redButton = new Button("Set panel color to red");

        public void init() {

            setLayout(new FlowLayout());



        public void actionPerformed(ActionEvent e) {
            if (e.getActionCommand() == "Set panel color to red"){
            else {}

          public static void main (String[] args){
              SimpleTest test = new SimpleTest();
              Frame mainFrame = new Frame("AWTModalTest2 application");
              mainFrame.addWindowListener( new WindowAdapter() {
                  public void windowClosing(WindowEvent e) {
              mainFrame.setSize(500, 300);

      =======================end SimpleTest.java=============================

      Try running this program on Windows (I used Windows 2000, and Windows 98). When frame shows up, maximize any other window so that it will cover SimpleTest. Then minimize the window to "uncover" SimpleTest. SimpleTest becomes active, but does not repaint itself - it has what ever was painted over it (the window we maximized to cover it up). This does not go away if I move SimpleTest around. The only thing that makes SimpleTest repaint itself is minimizing it and maximizing it again.
      This does not happen if you bring up SimpleTest, then cover it with any other window, and then maximize SimpleTest (by clicking on its icon in the tray). This happens only if you minimize the window that covered SimpleTest and SimpleTest becomes active (in focus) but only because we uncovered it, not because it was maximized.
      While it is not too much to ask from user to minimize and maximize application, it is much more complicated when we are dealing with applets. User could navigate from the original screen of the applet (for example we popup some info window), then bring something over that window, then try to minimize whatever covered our popup window and see the print from the previous window on the popup. In addition to that, with applets, even if I minimize and maximise browser's window applet does not repaint itself... untill I Reload the page.
      This happens with both - Netscape and IE on Windows. does not happen on Solaris.
      A good example is http://pcne.east/~mfisher/Test_progress/Test2/demo_both.html
      On the page you will see two applets. First one repaints fine - it extends JApplet and has a JPanel. The second applet extends Applet and has Panel on it. Second applet will repaint fine if I add JPanel (instead of Panel) to it.
      No matter what you do - minimize, maximize - the second applet will not repaint. This is a high visibility bug and a lot of customers complain about it.
      The problem seems to be with Panel, since I was able to use my SimpleTest application and reproduce the problem.
      Attached is the gif file which has SimpleTest with some garbage on the background.


          Issue Links



              rraysunw Richard Ray (Inactive)
              mafishersunw Margarita Fisher (Inactive)
              0 Vote for this issue
              0 Start watching this issue