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

Image doesn't appear on JPanel when window is brought to foreground under the classic theme

    XMLWordPrintable

    Details

      Description

      Consider following code (in attachment, MyClipboardTest.zip):

      public class ImageTransferGUI {

          public static int paintCount = 0;

          TestFrame frame1;
          JButton copy;
          Image image1;

          public ImageTransferGUI() {
             image1 = Toolkit.getDefaultToolkit().getImage((new java.io.File(System.getProperty("test.src", "."), "duke_swim.gif")).toString());
              frame1=new TestFrame(true,image1);
              System.out.println("Inside contrucor...");
              copy=new JButton("copy");
              frame1.getContentPane().add("South",copy);
              frame1.setBounds(10,350,200,200);
              frame1.setVisible(true);
          }

          public static void main(String[] args){
              new ImageTransferGUI();//.frame1.toFront();
          }

          //The frame class used in the test
          class TestFrame extends JFrame {
              boolean show;
              Image img;
              public TestFrame(boolean show,Image img){
                  this.show=show;
                  this.img=img;
              }

              public void paint( Graphics g ){
                      System.out.println("paintCount: " + ++ImageTransferGUI.paintCount);
      super.paint();
                      g.drawImage( this.img, 30, 30, this );

              }
          }
      }

      When you lauch this class, drag the GUI window on top of another application's window, so that when you switch to that application it could completely hide our JFrame window. Switch to that application using Alt-Tab or by clicking other application's icon in the taskbar (but NOT by minimizing our JFrame window). Then switch back to our java application. The image drawn on JFrame is gone.

      TestFrame.paint() is not invoked in this case (as shows printing into console paintCount variable)

      This behavior is Windows-specific, does not happen on linux.
      The behavior is also Swing-specific, does not repeat with java.awt.Frame

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              ssadetsky Semyon Sadetsky (Inactive)
              Reporter:
              vabetkin Vitalii Abetkin (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: