| Constructor: |
public Dialog(Frame owner) {
this(owner, "", false);
}
Constructs an initially invisible, modeless Dialog with
the specified owner Frame and an empty title. Parameters:
owner - the owner of the dialog or null if
this dialog has no owner
Throws:
java.lang.IllegalArgumentException - if the owner's
GraphicsConfiguration is not from a screen device
HeadlessException - when
GraphicsEnvironment.isHeadless() returns true
Also see:
- java.awt.GraphicsEnvironment#isHeadless
- Component#setSize
- Component#setVisible
- exception:
java.lang.IllegalArgumentException - if the owner's
GraphicsConfiguration is not from a screen device
- exception:
HeadlessException - when
GraphicsEnvironment.isHeadless() returns true
|
public Dialog(Dialog owner) {
this(owner, "", false);
}
Constructs an initially invisible, modeless Dialog with
the specified owner Dialog and an empty title. Parameters:
owner - the owner of the dialog or null if this
dialog has no owner
Throws:
java.lang.IllegalArgumentException - if the owner's
GraphicsConfiguration is not from a screen device
HeadlessException - when
GraphicsEnvironment.isHeadless() returns true
Also see:
- java.awt.GraphicsEnvironment#isHeadless
- exception:
java.lang.IllegalArgumentException - if the owner's
GraphicsConfiguration is not from a screen device
- exception:
HeadlessException - when
GraphicsEnvironment.isHeadless() returns true
- since:
1.2 -
|
public Dialog(Window owner) {
this(owner, null, ModalityType.MODELESS);
}
Constructs an initially invisible, modeless Dialog with the
specified owner Window and an empty title. Parameters:
owner - the owner of the dialog. The owner must be an instance of
Dialog , Frame , any
of their descendents or null
Throws:
java.lang.IllegalArgumentException - if the owner
is not an instance of Dialog or Frame
java.lang.IllegalArgumentException - if the owner's
GraphicsConfiguration is not from a screen device
HeadlessException - when
GraphicsEnvironment.isHeadless() returns true
Also see:
- java.awt.GraphicsEnvironment#isHeadless
- exception:
java.lang.IllegalArgumentException - if the owner
is not an instance of Dialog or Frame
- exception:
java.lang.IllegalArgumentException - if the owner's
GraphicsConfiguration is not from a screen device
- exception:
HeadlessException - when
GraphicsEnvironment.isHeadless() returns true
- since:
1.6 -
|
public Dialog(Frame owner,
boolean modal) {
this(owner, "", modal);
}
Constructs an initially invisible Dialog with the specified
owner Frame and modality and an empty title. Parameters:
owner - the owner of the dialog or null if
this dialog has no owner
modal - specifes whether dialog blocks user input to other top-level
windows when shown. If false, the dialog is MODELESS;
if true, the modality type property is set to
DEFAULT_MODALITY_TYPE
Throws:
java.lang.IllegalArgumentException - if the owner's
GraphicsConfiguration is not from a screen device
HeadlessException - when
GraphicsEnvironment.isHeadless() returns true
Also see:
- java.awt.Dialog.ModalityType
- java.awt.Dialog.ModalityType#MODELESS
- java.awt.Dialog#DEFAULT_MODALITY_TYPE
- java.awt.Dialog#setModal
- java.awt.Dialog#setModalityType
- java.awt.GraphicsEnvironment#isHeadless
- exception:
java.lang.IllegalArgumentException - if the owner's
GraphicsConfiguration is not from a screen device
- exception:
HeadlessException - when
GraphicsEnvironment.isHeadless() returns true
|
public Dialog(Frame owner,
String title) {
this(owner, title, false);
}
Constructs an initially invisible, modeless Dialog with
the specified owner Frame and title. Parameters:
owner - the owner of the dialog or null if
this dialog has no owner
title - the title of the dialog or null if this dialog
has no title
Throws:
IllegalArgumentException - if the owner's
GraphicsConfiguration is not from a screen device
HeadlessException - when
GraphicsEnvironment.isHeadless() returns true
Also see:
- java.awt.GraphicsEnvironment#isHeadless
- Component#setSize
- Component#setVisible
- exception:
IllegalArgumentException - if the owner's
GraphicsConfiguration is not from a screen device
- exception:
HeadlessException - when
GraphicsEnvironment.isHeadless() returns true
|
public Dialog(Dialog owner,
String title) {
this(owner, title, false);
}
Constructs an initially invisible, modeless Dialog
with the specified owner Dialog and title. Parameters:
owner - the owner of the dialog or null if this
has no owner
title - the title of the dialog or null if this dialog
has no title
Throws:
java.lang.IllegalArgumentException - if the owner's
GraphicsConfiguration is not from a screen device
HeadlessException - when
GraphicsEnvironment.isHeadless() returns true
Also see:
- java.awt.GraphicsEnvironment#isHeadless
- exception:
java.lang.IllegalArgumentException - if the owner's
GraphicsConfiguration is not from a screen device
- exception:
HeadlessException - when
GraphicsEnvironment.isHeadless() returns true
- since:
1.2 -
|
public Dialog(Window owner,
String title) {
this(owner, title, ModalityType.MODELESS);
}
Constructs an initially invisible, modeless Dialog with
the specified owner Window and title. Parameters:
owner - the owner of the dialog. The owner must be an instance of
Dialog , Frame , any
of their descendents or null
title - the title of the dialog or null if this dialog
has no title
Throws:
java.lang.IllegalArgumentException - if the owner
is not an instance of Dialog or Frame
java.lang.IllegalArgumentException - if the owner's
GraphicsConfiguration is not from a screen device
HeadlessException - when
GraphicsEnvironment.isHeadless() returns true
Also see:
- java.awt.GraphicsEnvironment#isHeadless
- exception:
java.lang.IllegalArgumentException - if the owner
is not an instance of Dialog or Frame
- exception:
java.lang.IllegalArgumentException - if the owner's
GraphicsConfiguration is not from a screen device
- exception:
HeadlessException - when
GraphicsEnvironment.isHeadless() returns true
- since:
1.6 -
|
public Dialog(Window owner,
Dialog.ModalityType modalityType) {
this(owner, null, modalityType);
}
Constructs an initially invisible Dialog with the
specified owner Window and modality and an empty title. Parameters:
owner - the owner of the dialog. The owner must be an instance of
Dialog , Frame , any
of their descendents or null
modalityType - specifies whether dialog blocks input to other
windows when shown. null value and unsupported modality
types are equivalent to MODELESS
Throws:
java.lang.IllegalArgumentException - if the owner
is not an instance of Dialog or Frame
java.lang.IllegalArgumentException - if the owner's
GraphicsConfiguration is not from a screen device
HeadlessException - when
GraphicsEnvironment.isHeadless() returns true
SecurityException - if the calling thread does not have permission
to create modal dialogs with the given modalityType
Also see:
- java.awt.Dialog.ModalityType
- java.awt.Dialog#setModal
- java.awt.Dialog#setModalityType
- java.awt.GraphicsEnvironment#isHeadless
- java.awt.Toolkit#isModalityTypeSupported
- exception:
java.lang.IllegalArgumentException - if the owner
is not an instance of Dialog or Frame
- exception:
java.lang.IllegalArgumentException - if the owner's
GraphicsConfiguration is not from a screen device
- exception:
HeadlessException - when
GraphicsEnvironment.isHeadless() returns true
- exception:
SecurityException - if the calling thread does not have permission
to create modal dialogs with the given modalityType
- since:
1.6 -
|
public Dialog(Frame owner,
String title,
boolean modal) {
this(owner, title, modal ? DEFAULT_MODALITY_TYPE : ModalityType.MODELESS);
}
Constructs an initially invisible Dialog with the
specified owner Frame, title and modality. Parameters:
owner - the owner of the dialog or null if
this dialog has no owner
title - the title of the dialog or null if this dialog
has no title
modal - specifes whether dialog blocks user input to other top-level
windows when shown. If false, the dialog is MODELESS;
if true, the modality type property is set to
DEFAULT_MODALITY_TYPE
Throws:
java.lang.IllegalArgumentException - if the owner's
GraphicsConfiguration is not from a screen device
HeadlessException - when
GraphicsEnvironment.isHeadless() returns true
Also see:
- java.awt.Dialog.ModalityType
- java.awt.Dialog.ModalityType#MODELESS
- java.awt.Dialog#DEFAULT_MODALITY_TYPE
- java.awt.Dialog#setModal
- java.awt.Dialog#setModalityType
- java.awt.GraphicsEnvironment#isHeadless
- Component#setSize
- Component#setVisible
- exception:
java.lang.IllegalArgumentException - if the owner's
GraphicsConfiguration is not from a screen device
- exception:
HeadlessException - when
GraphicsEnvironment.isHeadless() returns true
|
public Dialog(Dialog owner,
String title,
boolean modal) {
this(owner, title, modal ? DEFAULT_MODALITY_TYPE : ModalityType.MODELESS);
}
Constructs an initially invisible Dialog with the
specified owner Dialog, title, and modality. Parameters:
owner - the owner of the dialog or null if this
dialog has no owner
title - the title of the dialog or null if this
dialog has no title
modal - specifes whether dialog blocks user input to other top-level
windows when shown. If false, the dialog is MODELESS;
if true, the modality type property is set to
DEFAULT_MODALITY_TYPE
Throws:
IllegalArgumentException - if the owner's
GraphicsConfiguration is not from a screen device
HeadlessException - when
GraphicsEnvironment.isHeadless() returns true
Also see:
- java.awt.Dialog.ModalityType
- java.awt.Dialog.ModalityType#MODELESS
- java.awt.Dialog#DEFAULT_MODALITY_TYPE
- java.awt.Dialog#setModal
- java.awt.Dialog#setModalityType
- java.awt.GraphicsEnvironment#isHeadless
- exception:
IllegalArgumentException - if the owner's
GraphicsConfiguration is not from a screen device
- exception:
HeadlessException - when
GraphicsEnvironment.isHeadless() returns true
- since:
1.2 -
|
public Dialog(Window owner,
String title,
Dialog.ModalityType modalityType) {
super(owner);
if ((owner != null) &&
!(owner instanceof Frame) &&
!(owner instanceof Dialog))
{
throw new IllegalArgumentException("Wrong parent window");
}
this.title = title;
setModalityType(modalityType);
SunToolkit.checkAndSetPolicy(this, false);
}
Constructs an initially invisible Dialog with the
specified owner Window, title and modality. Parameters:
owner - the owner of the dialog. The owner must be an instance of
Dialog , Frame , any
of their descendents or null
title - the title of the dialog or null if this dialog
has no title
modalityType - specifies whether dialog blocks input to other
windows when shown. null value and unsupported modality
types are equivalent to MODELESS
Throws:
java.lang.IllegalArgumentException - if the owner
is not an instance of Dialog or Frame
java.lang.IllegalArgumentException - if the owner's
GraphicsConfiguration is not from a screen device
HeadlessException - when
GraphicsEnvironment.isHeadless() returns true
SecurityException - if the calling thread does not have permission
to create modal dialogs with the given modalityType
Also see:
- java.awt.Dialog.ModalityType
- java.awt.Dialog#setModal
- java.awt.Dialog#setModalityType
- java.awt.GraphicsEnvironment#isHeadless
- java.awt.Toolkit#isModalityTypeSupported
- exception:
java.lang.IllegalArgumentException - if the owner
is not an instance of Dialog or Frame
- exception:
java.lang.IllegalArgumentException - if the owner's
GraphicsConfiguration is not from a screen device
- exception:
HeadlessException - when
GraphicsEnvironment.isHeadless() returns true
- exception:
SecurityException - if the calling thread does not have permission
to create modal dialogs with the given modalityType
- since:
1.6 -
|
public Dialog(Frame owner,
String title,
boolean modal,
GraphicsConfiguration gc) {
this(owner, title, modal ? DEFAULT_MODALITY_TYPE : ModalityType.MODELESS, gc);
}
Constructs an initially invisible Dialog with the specified owner
Frame, title, modality, and GraphicsConfiguration. Parameters:
owner - the owner of the dialog or null if this dialog
has no owner
title - the title of the dialog or null if this dialog
has no title
modal - specifes whether dialog blocks user input to other top-level
windows when shown. If false, the dialog is MODELESS;
if true, the modality type property is set to
DEFAULT_MODALITY_TYPE
gc - the GraphicsConfiguration of the target screen device;
if null, the default system GraphicsConfiguration
is assumed
Throws:
java.lang.IllegalArgumentException - if gc
is not from a screen device
HeadlessException - when
GraphicsEnvironment.isHeadless() returns true
Also see:
- java.awt.Dialog.ModalityType
- java.awt.Dialog.ModalityType#MODELESS
- java.awt.Dialog#DEFAULT_MODALITY_TYPE
- java.awt.Dialog#setModal
- java.awt.Dialog#setModalityType
- java.awt.GraphicsEnvironment#isHeadless
- Component#setSize
- Component#setVisible
- exception:
java.lang.IllegalArgumentException - if gc
is not from a screen device
- exception:
HeadlessException - when
GraphicsEnvironment.isHeadless() returns true
- since:
1.4 -
|
public Dialog(Dialog owner,
String title,
boolean modal,
GraphicsConfiguration gc) {
this(owner, title, modal ? DEFAULT_MODALITY_TYPE : ModalityType.MODELESS, gc);
}
Constructs an initially invisible Dialog with the
specified owner Dialog, title, modality and
GraphicsConfiguration. Parameters:
owner - the owner of the dialog or null if this
dialog has no owner
title - the title of the dialog or null if this
dialog has no title
modal - specifes whether dialog blocks user input to other top-level
windows when shown. If false, the dialog is MODELESS;
if true, the modality type property is set to
DEFAULT_MODALITY_TYPE
gc - the GraphicsConfiguration of the target screen device;
if null, the default system GraphicsConfiguration
is assumed
Throws:
java.lang.IllegalArgumentException - if gc
is not from a screen device
HeadlessException - when
GraphicsEnvironment.isHeadless() returns true
Also see:
- java.awt.Dialog.ModalityType
- java.awt.Dialog.ModalityType#MODELESS
- java.awt.Dialog#DEFAULT_MODALITY_TYPE
- java.awt.Dialog#setModal
- java.awt.Dialog#setModalityType
- java.awt.GraphicsEnvironment#isHeadless
- Component#setSize
- Component#setVisible
- exception:
java.lang.IllegalArgumentException - if gc
is not from a screen device
- exception:
HeadlessException - when
GraphicsEnvironment.isHeadless() returns true
- since:
1.4 -
|
public Dialog(Window owner,
String title,
Dialog.ModalityType modalityType,
GraphicsConfiguration gc) {
super(owner, gc);
if ((owner != null) &&
!(owner instanceof Frame) &&
!(owner instanceof Dialog))
{
throw new IllegalArgumentException("wrong owner window");
}
this.title = title;
setModalityType(modalityType);
SunToolkit.checkAndSetPolicy(this, false);
}
Constructs an initially invisible Dialog with the
specified owner Window, title, modality and
GraphicsConfiguration. Parameters:
owner - the owner of the dialog. The owner must be an instance of
Dialog , Frame , any
of their descendents or null
title - the title of the dialog or null if this dialog
has no title
modalityType - specifies whether dialog blocks input to other
windows when shown. null value and unsupported modality
types are equivalent to MODELESS
gc - the GraphicsConfiguration of the target screen device;
if null, the default system GraphicsConfiguration
is assumed
Throws:
java.lang.IllegalArgumentException - if the owner
is not an instance of Dialog or Frame
java.lang.IllegalArgumentException - if gc
is not from a screen device
HeadlessException - when
GraphicsEnvironment.isHeadless() returns true
SecurityException - if the calling thread does not have permission
to create modal dialogs with the given modalityType
Also see:
- java.awt.Dialog.ModalityType
- java.awt.Dialog#setModal
- java.awt.Dialog#setModalityType
- java.awt.GraphicsEnvironment#isHeadless
- java.awt.Toolkit#isModalityTypeSupported
- exception:
java.lang.IllegalArgumentException - if the owner
is not an instance of Dialog or Frame
- exception:
java.lang.IllegalArgumentException - if gc
is not from a screen device
- exception:
HeadlessException - when
GraphicsEnvironment.isHeadless() returns true
- exception:
SecurityException - if the calling thread does not have permission
to create modal dialogs with the given modalityType
- since:
1.6 -
|
| Method from java.awt.Dialog Detail: |
public void addNotify() {
synchronized (getTreeLock()) {
if (parent != null && parent.getPeer() == null) {
parent.addNotify();
}
if (peer == null) {
peer = getToolkit().createDialog(this);
}
super.addNotify();
}
}
Makes this Dialog displayable by connecting it to
a native screen resource. Making a dialog displayable will
cause any of its children to be made displayable.
This method is called internally by the toolkit and should
not be called directly by programs. |
void blockWindow(Window w) {
if (!w.isModalBlocked()) {
w.setModalBlocked(this, true, true);
blockedWindows.add(w);
}
}
|
void blockWindows(List toBlock) {
DialogPeer dpeer = (DialogPeer)peer;
if (dpeer == null) {
return;
}
Iterator< Window > it = toBlock.iterator();
while (it.hasNext()) {
Window w = it.next();
if (!w.isModalBlocked()) {
w.setModalBlocked(this, true, false);
} else {
it.remove();
}
}
dpeer.blockWindows(toBlock);
blockedWindows.addAll(toBlock);
}
|
static void checkShouldBeBlocked(Window w) {
synchronized (w.getTreeLock()) {
for (int i = 0; i < modalDialogs.size(); i++) {
Dialog modalDialog = modalDialogs.get(i);
if (modalDialog.shouldBlock(w)) {
modalDialog.blockWindow(w);
break;
}
}
}
}
|
String constructComponentName() {
synchronized (Dialog.class) {
return base + nameCounter++;
}
}
Construct a name for this component. Called by getName() when the
name is null. |
void doDispose() {
// fix for 5048370: set isInDispose flag to true to prevent calling
// to hideAndDisposeHandler() from hide()
isInDispose = true;
super.doDispose();
hideAndDisposeHandler();
isInDispose = false;
}
Disposes the Dialog and then causes show() to return if it is currently
blocked. |
public AccessibleContext getAccessibleContext() {
if (accessibleContext == null) {
accessibleContext = new AccessibleAWTDialog();
}
return accessibleContext;
}
Gets the AccessibleContext associated with this Dialog.
For dialogs, the AccessibleContext takes the form of an
AccessibleAWTDialog.
A new AccessibleAWTDialog instance is created if necessary. |
public Dialog.ModalityType getModalityType() {
return modalityType;
}
Returns the modality type of this dialog. |
public String getTitle() {
return title;
}
Gets the title of the dialog. The title is displayed in the
dialog's border. |
public void hide() {
hideAndDisposePreHandler();
super.hide();
// fix for 5048370: if hide() is called from super.doDispose(), then
// hideAndDisposeHandler() should not be called here as it will be called
// at the end of doDispose()
if (!isInDispose) {
hideAndDisposeHandler();
}
} Deprecated! As - of JDK version 1.5, replaced by
setVisible(boolean) .
Hides the Dialog and then causes {@code show} to return if it is currently
blocked. |
void interruptBlocking() {
if (isModal()) {
disposeImpl();
} else if (windowClosingException != null) {
windowClosingException.fillInStackTrace();
windowClosingException.printStackTrace();
windowClosingException = null;
}
}
|
public boolean isModal() {
return isModal_NoClientCode();
}
|
final boolean isModal_NoClientCode() {
return modalityType != ModalityType.MODELESS;
}
|
public boolean isResizable() {
return resizable;
}
Indicates whether this dialog is resizable by the user.
By default, all dialogs are initially resizable. |
public boolean isUndecorated() {
return undecorated;
}
Indicates whether this dialog is undecorated.
By default, all dialogs are initially decorated. |
void modalHide() {
// we should unblock all the windows first...
IdentityArrayList< Window > save = new IdentityArrayList< Window >();
int blockedWindowsCount = blockedWindows.size();
for (int i = 0; i < blockedWindowsCount; i++) {
Window w = blockedWindows.get(0);
save.add(w);
unblockWindow(w); // also removes w from blockedWindows
}
// ... and only after that check if they should be blocked
// by another dialogs
for (int i = 0; i < blockedWindowsCount; i++) {
Window w = save.get(i);
if ((w instanceof Dialog) && ((Dialog)w).isModal_NoClientCode()) {
Dialog d = (Dialog)w;
d.modalShow();
} else {
checkShouldBeBlocked(w);
}
}
}
|
void modalShow() {
// find all the dialogs that block this one
IdentityArrayList< Dialog > blockers = new IdentityArrayList< Dialog >();
for (Dialog d : modalDialogs) {
if (d.shouldBlock(this)) {
Window w = d;
while ((w != null) && (w != this)) {
w = (Window)(w.getOwner_NoClientCode());
}
if ((w == this) || !shouldBlock(d) || (modalityType.compareTo(d.getModalityType()) < 0)) {
blockers.add(d);
}
}
}
// add all blockers' blockers to blockers :)
for (int i = 0; i < blockers.size(); i++) {
Dialog blocker = blockers.get(i);
if (blocker.isModalBlocked()) {
Dialog blockerBlocker = blocker.getModalBlocker();
if (!blockers.contains(blockerBlocker)) {
blockers.add(i + 1, blockerBlocker);
}
}
}
if (blockers.size() > 0) {
blockers.get(0).blockWindow(this);
}
// find all windows from blockers' hierarchies
IdentityArrayList< Window > blockersHierarchies = new IdentityArrayList< Window >(blockers);
int k = 0;
while (k < blockersHierarchies.size()) {
Window w = blockersHierarchies.get(k);
Window[] ownedWindows = w.getOwnedWindows_NoClientCode();
for (Window win : ownedWindows) {
blockersHierarchies.add(win);
}
k++;
}
java.util.List< Window > toBlock = new IdentityLinkedList< Window >();
// block all windows from scope of blocking except from blockers' hierarchies
IdentityArrayList< Window > unblockedWindows = Window.getAllUnblockedWindows();
for (Window w : unblockedWindows) {
if (shouldBlock(w) && !blockersHierarchies.contains(w)) {
if ((w instanceof Dialog) && ((Dialog)w).isModal_NoClientCode()) {
Dialog wd = (Dialog)w;
if (wd.shouldBlock(this) && (modalDialogs.indexOf(wd) > modalDialogs.indexOf(this))) {
continue;
}
}
toBlock.add(w);
}
}
blockWindows(toBlock);
if (!isModalBlocked()) {
updateChildrenBlocking();
}
}
|
final void modalityPopped() {
Toolkit tk = Toolkit.getDefaultToolkit();
if (tk instanceof SunToolkit) {
SunToolkit stk = (SunToolkit)tk;
stk.notifyModalityPopped(this);
}
}
|
final void modalityPushed() {
Toolkit tk = Toolkit.getDefaultToolkit();
if (tk instanceof SunToolkit) {
SunToolkit stk = (SunToolkit)tk;
stk.notifyModalityPushed(this);
}
}
|
protected String paramString() {
String str = super.paramString() + "," + modalityType;
if (title != null) {
str += ",title=" + title;
}
return str;
}
Returns a string representing the state of this dialog. This
method is intended to be used only for debugging purposes, and the
content and format of the returned string may vary between
implementations. The returned string may be empty but may not be
null. |
public void setModal(boolean modal) {
this.modal = modal;
setModalityType(modal ? DEFAULT_MODALITY_TYPE : ModalityType.MODELESS);
}
Specifies whether this dialog should be modal.
This method is obsolete and is kept for backwards compatibility only.
Use setModalityType() instead.
Note: changing modality of the visible dialog may have no effect
until it is hidden and then shown again. |
public void setModalityType(Dialog.ModalityType type) {
if (type == null) {
type = Dialog.ModalityType.MODELESS;
}
if (!Toolkit.getDefaultToolkit().isModalityTypeSupported(type)) {
type = Dialog.ModalityType.MODELESS;
}
if (modalityType == type) {
return;
}
if (type == ModalityType.TOOLKIT_MODAL) {
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
sm.checkPermission(SecurityConstants.TOOLKIT_MODALITY_PERMISSION);
}
}
modalityType = type;
modal = (modalityType != ModalityType.MODELESS);
}
Sets the modality type for this dialog. See ModalityType for possible modality types.
If the given modality type is not supported, MODELESS
is used. You may want to call getModalityType() after calling
this method to ensure that the modality type has been set.
Note: changing modality of the visible dialog may have no effect
until it is hidden and then shown again. |
public void setResizable(boolean resizable) {
boolean testvalid = false;
synchronized (this) {
this.resizable = resizable;
DialogPeer peer = (DialogPeer)this.peer;
if (peer != null) {
peer.setResizable(resizable);
testvalid = true;
}
}
// On some platforms, changing the resizable state affects
// the insets of the Dialog. If we could, we'd call invalidate()
// from the peer, but we need to guarantee that we're not holding
// the Dialog lock when we call invalidate().
if (testvalid && valid) {
invalidate();
}
}
Sets whether this dialog is resizable by the user. |
public void setTitle(String title) {
String oldTitle = this.title;
synchronized(this) {
this.title = title;
DialogPeer peer = (DialogPeer)this.peer;
if (peer != null) {
peer.setTitle(title);
}
}
firePropertyChange("title", oldTitle, title);
}
Sets the title of the Dialog. |
public void setUndecorated(boolean undecorated) {
/* Make sure we don't run in the middle of peer creation.*/
synchronized (getTreeLock()) {
if (isDisplayable()) {
throw new IllegalComponentStateException("The dialog is displayable.");
}
this.undecorated = undecorated;
}
}
Disables or enables decorations for this dialog.
This method can only be called while the dialog is not displayable. |
public void setVisible(boolean b) {
super.setVisible(b);
}
Shows or hides this {@code Dialog} depending on the value of parameter
{@code b}. |
boolean shouldBlock(Window w) {
if (!isVisible_NoClientCode() ||
(!w.isVisible_NoClientCode() && !w.isInShow) ||
isInHide ||
(w == this) ||
!isModal_NoClientCode())
{
return false;
}
if ((w instanceof Dialog) && ((Dialog)w).isInHide) {
return false;
}
// check if w is from children hierarchy
// fix for 6271546: we should also take into consideration child hierarchies
// of this dialog's blockers
Window blockerToCheck = this;
while (blockerToCheck != null) {
Component c = w;
while ((c != null) && (c != blockerToCheck)) {
c = c.getParent_NoClientCode();
}
if (c == blockerToCheck) {
return false;
}
blockerToCheck = blockerToCheck.getModalBlocker();
}
switch (modalityType) {
case MODELESS:
return false;
case DOCUMENT_MODAL:
if (w.isModalExcluded(ModalExclusionType.APPLICATION_EXCLUDE)) {
// application- and toolkit-excluded windows are not blocked by
// document-modal dialogs from outside their children hierarchy
Component c = this;
while ((c != null) && (c != w)) {
c = c.getParent_NoClientCode();
}
return c == w;
} else {
return getDocumentRoot() == w.getDocumentRoot();
}
case APPLICATION_MODAL:
return !w.isModalExcluded(ModalExclusionType.APPLICATION_EXCLUDE) &&
(appContext == w.appContext);
case TOOLKIT_MODAL:
return !w.isModalExcluded(ModalExclusionType.TOOLKIT_EXCLUDE);
}
return false;
}
|
public void show() {
beforeFirstShow = false;
if (!isModal()) {
conditionalShow(null, null);
} else {
// Set this variable before calling conditionalShow(). That
// way, if the Dialog is hidden right after being shown, we
// won't mistakenly block this thread.
keepBlockingEDT = true;
keepBlockingCT = true;
// Store the app context on which this dialog is being shown.
// Event dispatch thread of this app context will be sleeping until
// we wake it by any event from hideAndDisposeHandler().
showAppContext = AppContext.getAppContext();
AtomicLong time = new AtomicLong();
Component predictedFocusOwner = null;
try {
predictedFocusOwner = getMostRecentFocusOwner();
if (conditionalShow(predictedFocusOwner, time)) {
// We have two mechanisms for blocking: 1. If we're on the
// EventDispatchThread, start a new event pump. 2. If we're
// on any other thread, call wait() on the treelock.
modalFilter = ModalEventFilter.createFilterForDialog(this);
final Runnable pumpEventsForFilter = new Runnable() {
public void run() {
EventDispatchThread dispatchThread =
(EventDispatchThread)Thread.currentThread();
dispatchThread.pumpEventsForFilter(new Conditional() {
public boolean evaluate() {
synchronized (getTreeLock()) {
return keepBlockingEDT && windowClosingException == null;
}
}
}, modalFilter);
}
};
// if this dialog is toolkit-modal, the filter should be added
// to all EDTs (for all AppContexts)
if (modalityType == ModalityType.TOOLKIT_MODAL) {
Iterator it = AppContext.getAppContexts().iterator();
while (it.hasNext()) {
AppContext appContext = (AppContext)it.next();
if (appContext == showAppContext) {
continue;
}
EventQueue eventQueue = (EventQueue)appContext.get(AppContext.EVENT_QUEUE_KEY);
// it may occur that EDT for appContext hasn't been started yet, so
// we post an empty invocation event to trigger EDT initialization
Runnable createEDT = new Runnable() {
public void run() {};
};
eventQueue.postEvent(new InvocationEvent(this, createEDT));
EventDispatchThread edt = eventQueue.getDispatchThread();
edt.addEventFilter(modalFilter);
}
}
modalityPushed();
try {
if (EventQueue.isDispatchThread()) {
/*
* dispose SequencedEvent we are dispatching on current
* AppContext, to prevent us from hang.
*
*/
// BugId 4531693 (son@sparc.spb.su)
SequencedEvent currentSequencedEvent = KeyboardFocusManager.
getCurrentKeyboardFocusManager().getCurrentSequencedEvent();
if (currentSequencedEvent != null) {
currentSequencedEvent.dispose();
}
/*
* Event processing is done inside doPrivileged block so that
* it wouldn't matter even if user code is on the stack
* Fix for BugId 6300270
*/
AccessController.doPrivileged(new PrivilegedAction() {
public Object run() {
pumpEventsForFilter.run();
return null;
}
});
} else {
synchronized (getTreeLock()) {
Toolkit.getEventQueue().postEvent(new PeerEvent(this,
pumpEventsForFilter,
PeerEvent.PRIORITY_EVENT));
while (keepBlockingCT && windowClosingException == null) {
try {
getTreeLock().wait();
} catch (InterruptedException e) {
break;
}
}
}
}
} finally {
modalityPopped();
}
// if this dialog is toolkit-modal, its filter must be removed
// from all EDTs (for all AppContexts)
if (modalityType == ModalityType.TOOLKIT_MODAL) {
Iterator it = AppContext.getAppContexts().iterator();
while (it.hasNext()) {
AppContext appContext = (AppContext)it.next();
if (appContext == showAppContext) {
continue;
}
EventQueue eventQueue = (EventQueue)appContext.get(AppContext.EVENT_QUEUE_KEY);
EventDispatchThread edt = eventQueue.getDispatchThread();
edt.removeEventFilter(modalFilter);
}
}
if (windowClosingException != null) {
windowClosingException.fillInStackTrace();
throw windowClosingException;
}
}
} finally {
if (predictedFocusOwner != null) {
// Restore normal key event dispatching
KeyboardFocusManager.getCurrentKeyboardFocusManager().
dequeueKeyEvents(time.get(), predictedFocusOwner);
}
}
}
} Deprecated! As - of JDK version 1.5, replaced by
setVisible(boolean) .
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.
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. |
public void toBack() {
super.toBack();
if (visible) {
synchronized (getTreeLock()) {
for (Window w : blockedWindows) {
w.toBack_NoClientCode();
}
}
}
}
{@inheritDoc}
If this dialog is modal and blocks some windows, then all of them are
also sent to the back to keep them below the blocking dialog. |
void unblockWindow(Window w) {
if (w.isModalBlocked() && blockedWindows.contains(w)) {
blockedWindows.remove(w);
w.setModalBlocked(this, false, true);
}
}
|