-
Bug
-
Resolution: Not an Issue
-
P3
-
7
-
generic
-
windows
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
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
- relates to
-
JDK-7180164 Moving mouse within JFrame causes button to get shown, the rest of painted stuff goes away
-
- Closed
-