src/share/classes/java/awt/Dialog.java
Print this page
@@ -38,10 +38,11 @@
import sun.awt.SunToolkit;
import sun.awt.PeerEvent;
import sun.awt.util.IdentityArrayList;
import sun.awt.util.IdentityLinkedList;
import java.security.AccessControlException;
+import java.util.function.BooleanSupplier;
/**
* 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.
*
@@ -1042,17 +1043,10 @@
Component predictedFocusOwner = null;
try {
predictedFocusOwner = getMostRecentFocusOwner();
if (conditionalShow(predictedFocusOwner, time)) {
modalFilter = ModalEventFilter.createFilterForDialog(this);
- final Conditional cond = new Conditional() {
- @Override
- public boolean evaluate() {
- return windowClosingException == null;
- }
- };
-
// if this dialog is toolkit-modal, the filter should be added
// to all EDTs (for all AppContexts)
if (modalityType == ModalityType.TOOLKIT_MODAL) {
Iterator<AppContext> it = AppContext.getAppContexts().iterator();
while (it.hasNext()) {
@@ -1061,28 +1055,21 @@
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));
+ eventQueue.postEvent(new InvocationEvent(this, () -> {}));
EventDispatchThread edt = eventQueue.getDispatchThread();
edt.addEventFilter(modalFilter);
}
}
modalityPushed();
try {
final EventQueue eventQueue = AccessController.doPrivileged(
- new PrivilegedAction<EventQueue>() {
- public EventQueue run() {
- return Toolkit.getDefaultToolkit().getSystemEventQueue();
- }
- });
- secondaryLoop = eventQueue.createSecondaryLoop(cond, modalFilter, 0);
+ (PrivilegedAction<EventQueue>) Toolkit.getDefaultToolkit()::getSystemEventQueue);
+ secondaryLoop = eventQueue.createSecondaryLoop(() -> true, modalFilter, 0);
if (!secondaryLoop.enter()) {
secondaryLoop = null;
}
} finally {
modalityPopped();
@@ -1100,15 +1087,10 @@
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().
@@ -1132,20 +1114,10 @@
SunToolkit stk = (SunToolkit)tk;
stk.notifyModalityPopped(this);
}
}
- void interruptBlocking() {
- if (isModal()) {
- disposeImpl();
- } else if (windowClosingException != null) {
- windowClosingException.fillInStackTrace();
- windowClosingException.printStackTrace();
- windowClosingException = null;
- }
- }
-
private void hideAndDisposePreHandler() {
isInHide = true;
synchronized (getTreeLock()) {
if (secondaryLoop != null) {
modalHide();