JDK-4780722 : Can't hide() minimized JWindow - and results in weird repaint
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 1.4.0
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_2000
  • CPU: x86
  • Submitted: 2002-11-18
  • Updated: 2006-02-20
  • Resolved: 2006-02-20
Related Reports
Duplicate :  
Description
Name: jk109818			Date: 11/18/2002


FULL PRODUCT VERSION :
java version "1.4.0_01"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0_01-b03)
Java HotSpot(TM) Client VM (build 1.4.0_01-b03, mixed mode)

AND

java version "1.4.1_01"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1_01-b01)
Java HotSpot(TM) Client VM (build 1.4.1_01-b01, mixed mode)


FULL OPERATING SYSTEM VERSION :
Microsoft Windows 2000 [Version
5.00.2195]

ADDITIONAL OPERATING SYSTEMS :
Microsoft Windows
XP

EXTRA RELEVANT SYSTEM CONFIGURATION :
Problem does NOT occur on Linux JDK1.4.0.

A DESCRIPTION OF THE PROBLEM :
Hiding a window while it is iconified results in the window being in a weird
never-never land between visible and not visible.  It's visible on your
screen, but doesn't repaint itself properly.  So the window winds up
displaying whatever was on its screen location before it was de-iconified
(i.e., the contents of other app windows).


STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
* open up a JFrame
* open up a JWindow over it, with the JFrame as its
owner
* iconify the frame (the window gets iconified too)
* call
hide() on the window while everything is iconified
* de-iconify the
frame

The result is that the window winds up in a weird never-never land
between visible and not visible.  It's visible on your screen, but doesn't
repaint itself properly.  So the window winds up displaying whatever was
on its screen location before it was de-iconified (i.e., the contents of
other app windows).  If you move the frame around on the screen you can
really see the phantom window being displayed over the frame.

Oh, and
to top this off, calling isVisible() and isShowing() on this phantom
window both say "true".  Near as I can tell they should both say "false".


EXPECTED VERSUS ACTUAL BEHAVIOR :
Expected:

* When owning Frame gets iconified, Window should also get
iconified.
* After a call to Window.hide() while iconified, Window
should respond with "false" for isVisible() and isShowing().
* After
de-iconifying the Frame, Window should not be
visible.


Actual:

* When owning Frame gets iconified, Window
DOES also get iconified.  (This is correct.)
* After a call to
Window.hide() while iconified, Window responds with "true" for
isVisible() and isShowing().  (This is incorrect.)
* After de-
iconifying the Frame, Window is visible - but cannot paint itself
properly.  (This is incorrect.)

ERROR MESSAGES/STACK TRACES THAT OCCUR :
No error messages.  Just incorrect behavior.

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class WindowTest extends JFrame {

	public static void main(String[]  args)
	{
		WindowTest  test = new WindowTest();
		test.show();
	}

	public WindowTest() 
	{
		setSize(640,480);
		getContentPane().setBackground(Color.BLUE);
		setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
		addWindowListener(
			new WindowAdapter() {
				public void windowClosing(WindowEvent e)
				{
					System.exit(0);
				}
				public void windowIconified(WindowEvent e)
				{
					System.out.println("window iconified");
					System.out.println("before isVisible:"+isVisible());
					System.out.println("before isShowing:"+isShowing());
					windowTest2.hide();
					System.out.println("after isVisible:"+isVisible());
					System.out.println("after isShowing:"+isShowing());
				}
			}
		);
	}

	public void	show() {
		Dimension screenDim = Toolkit.getDefaultToolkit().getScreenSize();
		Rectangle frameDim =
					getBounds();
		setLocation((screenDim.width-frameDim.width)/2, (screenDim.height -
					frameDim.height)/2);

		super.show();
		windowTest2.show();
	}

	private WindowTest2  windowTest2 = new WindowTest2(this);
}

class WindowTest2 extends JWindow {

	public WindowTest2(Frame  f) {
		super(f);
		setSize(100,100);
		getContentPane().setBackground(Color.YELLOW);
	}


	public void show() {
		Dimension screenDim =
  					Toolkit.getDefaultToolkit().getScreenSize();
		Rectangle frameDim =
					getBounds();
		setLocation((screenDim.width-frameDim.width)/2, (screenDim.height-
					frameDim.height)/2);

		super.show();
	}
}
---------- END SOURCE ----------
(Review ID: 159963) 
======================================================================