jdk/src/share/classes/java/awt/Dialog.java
Print this page
rev 5717 : 8004341: Two JCK tests fails with 7u11 b06
Reviewed-by: serb, skoivu
*** 37,46 ****
--- 37,47 ----
import sun.awt.SunToolkit;
import sun.awt.PeerEvent;
import sun.awt.util.IdentityArrayList;
import sun.awt.util.IdentityLinkedList;
import sun.security.util.SecurityConstants;
+ import java.security.AccessControlException;
/**
* A Dialog is a top-level window with a title and a border
* that is typically used to take some form of input from the user.
*
*** 126,135 ****
--- 127,138 ----
* @see Component#isDisplayable()
* @since 1.4
*/
boolean undecorated = false;
+ private transient boolean initialized = false;
+
/**
* Modal dialogs block all input to some top-level windows.
* Whether a particular window is blocked depends on dialog's type
* of modality; this is called the "scope of blocking". The
* <code>ModalityType</code> enum specifies modal types and their
*** 669,678 ****
--- 672,682 ----
}
this.title = title;
setModalityType(modalityType);
SunToolkit.checkAndSetPolicy(this);
+ initialized = true;
}
/**
* Constructs an initially invisible <code>Dialog</code> with the
* specified owner <code>Window</code>, title, modality and
*** 720,729 ****
--- 724,734 ----
}
this.title = title;
setModalityType(modalityType);
SunToolkit.checkAndSetPolicy(this);
+ initialized = true;
}
/**
* Construct a name for this component. Called by getName() when the
* name is null.
*** 849,864 ****
type = Dialog.ModalityType.MODELESS;
}
if (modalityType == type) {
return;
}
! if (type == ModalityType.TOOLKIT_MODAL) {
! SecurityManager sm = System.getSecurityManager();
! if (sm != null) {
! sm.checkPermission(SecurityConstants.AWT.TOOLKIT_MODALITY_PERMISSION);
! }
! }
modalityType = type;
modal = (modalityType != ModalityType.MODELESS);
}
/**
--- 854,866 ----
type = Dialog.ModalityType.MODELESS;
}
if (modalityType == type) {
return;
}
!
! checkModalityPermission(type);
!
modalityType = type;
modal = (modalityType != ModalityType.MODELESS);
}
/**
*** 1023,1032 ****
--- 1025,1037 ----
* @deprecated As of JDK version 1.5, replaced by
* {@link #setVisible(boolean) setVisible(boolean)}.
*/
@Deprecated
public void show() {
+ if (!initialized) throw new IllegalStateException(
+ "The dialog component has not been initialized properly");
+
beforeFirstShow = false;
if (!isModal()) {
conditionalShow(null, null);
} else {
AppContext showAppContext = AppContext.getAppContext();
*** 1598,1619 ****
}
}
}
}
private void readObject(ObjectInputStream s)
throws ClassNotFoundException, IOException, HeadlessException
{
GraphicsEnvironment.checkHeadless();
! s.defaultReadObject();
// in 1.5 or earlier modalityType was absent, so use "modal" instead
! if (modalityType == null) {
setModal(modal);
}
blockedWindows = new IdentityArrayList();
}
/*
* --- Accessibility Support ---
*
--- 1603,1657 ----
}
}
}
}
+ private void checkModalityPermission(ModalityType mt) {
+ if (mt == ModalityType.TOOLKIT_MODAL) {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm != null) {
+ sm.checkPermission(
+ SecurityConstants.AWT.TOOLKIT_MODALITY_PERMISSION
+ );
+ }
+ }
+ }
+
private void readObject(ObjectInputStream s)
throws ClassNotFoundException, IOException, HeadlessException
{
GraphicsEnvironment.checkHeadless();
!
! java.io.ObjectInputStream.GetField fields =
! s.readFields();
!
! ModalityType localModalityType = (ModalityType)fields.get("modalityType", null);
!
! try {
! checkModalityPermission(localModalityType);
! } catch (AccessControlException ace) {
! localModalityType = DEFAULT_MODALITY_TYPE;
! }
// in 1.5 or earlier modalityType was absent, so use "modal" instead
! if (localModalityType == null) {
! this.modal = fields.get("modal", false);
setModal(modal);
+ } else {
+ this.modalityType = localModalityType;
}
+ this.resizable = fields.get("resizable", true);
+ this.undecorated = fields.get("undecorated", false);
+ this.title = (String)fields.get("title", "");
+
blockedWindows = new IdentityArrayList();
+
+ SunToolkit.checkAndSetPolicy(this);
+
+ initialized = true;
+
}
/*
* --- Accessibility Support ---
*