JDK-5047523 : java.awt.Window/Dialog.setVisible() semantics lost
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 5.0
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2004-05-14
  • Updated: 2017-05-16
  • Resolved: 2005-07-12
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 6
6 b43Fixed
Related Reports
Relates :  
Description
Background: In java.awt.Window and java.awt.Dialog, the Component.show() method is overridden to provide some additional behaviors as documented in the JDK 1.4.2 spec (such as bringing the window to the front).  Also, Window/Dialog.setVisible() inherit from Component.setVisible(), which delegates to Component.show() for its implementation.

There are two problems:

1) In JDK 1.5, Window/Dialog.show() have been marked as deprecated (good - see bug 4689044) and the specifications of these methods have been removed (bad).  That means that there is no longer any specification of the additional semantics required of the show() and setVisible() methods on Window and Dialog.

2) In JDK 1.1 - JDK 1.4, the specifications for Window/Dialog.show() documented the additional behaviors provided by these methods, but the specification for Window/Dialog.setVisible() did not -- this method was simply inherited from Component.setVisible().  This has led at least one customer to conclude that show() and setVisible() on these classes have different semantics, when actually they are identical.

See suggested fix.

###@###.### 2004-05-14

Comments
SUGGESTED FIX In Window and Dialog, override the setVisible(boolean b) methods with super.setVisible(b); then copy the specification for the show() method from JDK 1.4.2 and paste it to the setVisible() method in each class. Leave the JDK 1.5 Window/Dialog.show() methods as they are (i.e., deprecated, without specifications). ###@###.### 2004-05-14 java.awt.Window: /** * Makes the Window visible. If the Window and/or its owner * are not yet displayable, both are made displayable. The * Window will be validated prior to being made visible. * If the Window is already visible, this will bring the Window * to the front. * @see Component#isDisplayable * @see #toFront * @deprecated As of JDK 5, replaced by * {@link setVisible(boolean) setVisible(boolean)}. */ @Deprecated public void show() /** * Hide this Window, its subcomponents, and all of its owned children. * The Window and its subcomponents can be made visible again * with a call to {@code show}. * </p> * @see #show * @see #dispose * @deprecated As of JDK 5, replaced by * {@link setVisible(boolean) setVisible(boolean)}. */ @Deprecated public void hide() /** * Shows or hides this {@code Window} depending on the value of parameter * {@code b}. * @param b if {@code true}, makes the {@code Window} visible, * otherwise hides the {@code Window}. * If the {@code Window} and/or its owner * are not yet displayable, both are made displayable. The * {@code Window} will be validated prior to being made visible. * If the {@codeWindow} is already visible, this will bring the {@code Window} * to the front.<p> * If {@code false}, hides this {@code Window}, its subcomponents, and all * of its owned children. * The {@code Window} and its subcomponents can be made visible again * with a call to {@code setVisible(true)}. * @see java.awt.Component#isDisplayable * @see java.awt.Component#setVisible * @see java.awt.Window#toFront * @see java.awt.Window#dispose */ public void setVisible(boolean b) java.awt.Dialog: /** * Makes the {@code Dialog} visible. If the dialog and/or its owner * are not yet displayable, both are made displayable. The * dialog will be validated prior to being made visible. * If the dialog is already visible, this will bring the dialog * to the front. * <p> * If the dialog is modal and is not already visible, this call * will not return until the dialog is hidden by calling hide or * dispose. It is permissible to show modal dialogs from the event * dispatching thread because the toolkit will ensure that another * event pump runs while the one which invoked this method is blocked. * @see Component#hide * @see Component#isDisplayable * @see Component#validate * @see #isModal * @see Window#setVisible(boolean) * @deprecated As of JDK version 1.5, replaced by * {@link setVisible(boolean) setVisible(boolean)}. */ @Deprecated public void show() /** * Hides the Dialog and then causes {@code show} to return if it is currently * blocked. * @see Window#show * @see Window#dispose * @see Window#setVisible(boolean) * @deprecated As of JDK version 1.5, replaced by * {@link setVisible(boolean) setVisible(boolean)}. */ @Deprecated public void hide() /** * Shows or hides this {@code Dialog} depending on the value of parameter * {@code b}. * @param b if {@code true}, makes the {@code Dialog} visible, * otherwise hides the {@code Dialog}. * If the dialog and/or its owner * are not yet displayable, both are made displayable. The * dialog will be validated prior to being made visible. * If {@code false}, hides the {@code Dialog} and then causes {@code setVisible(true)} * to return if it is currently blocked. * <p> * <b>Notes for modal dialogs</b>. * <ul> * <li>{@code setVisible(true)}: If the dialog is not already * visible, this call will not return until the dialog is * hidden by calling {@code setVisible(false)} or * {@code dispose}. * <li>{@code setVisible(false)}: Hides the dialog and then * returns on {@code setVisible(true)} if it is currently blocked. * <li>It is OK to call this method from the event dispatching * thread because the toolkit ensures that other events are * not blocked while this method is blocked. * </ul> * @see java.awt.Window#setVisible * @see java.awt.Window#dispose * @see java.awt.Component#isDisplayable * @see java.awt.Component#validate * @see java.awt.Dialog#isModal */ public void setVisible(boolean b) ###@###.### 2005-06-08 09:53:15 GMT
08-06-2005

EVALUATION ###@###.### 2004-05-18
18-05-2004