1020 * @see Component#validate
1021 * @see #isModal
1022 * @see Window#setVisible(boolean)
1023 * @deprecated As of JDK version 1.5, replaced by
1024 * {@link #setVisible(boolean) setVisible(boolean)}.
1025 */
1026 @Deprecated
1027 public void show() {
1028 beforeFirstShow = false;
1029 if (!isModal()) {
1030 conditionalShow(null, null);
1031 } else {
1032 AppContext showAppContext = AppContext.getAppContext();
1033
1034 AtomicLong time = new AtomicLong();
1035 Component predictedFocusOwner = null;
1036 try {
1037 predictedFocusOwner = getMostRecentFocusOwner();
1038 if (conditionalShow(predictedFocusOwner, time)) {
1039 modalFilter = ModalEventFilter.createFilterForDialog(this);
1040 Conditional cond = new Conditional() {
1041 @Override
1042 public boolean evaluate() {
1043 return windowClosingException == null;
1044 }
1045 };
1046
1047 // if this dialog is toolkit-modal, the filter should be added
1048 // to all EDTs (for all AppContexts)
1049 if (modalityType == ModalityType.TOOLKIT_MODAL) {
1050 Iterator it = AppContext.getAppContexts().iterator();
1051 while (it.hasNext()) {
1052 AppContext appContext = (AppContext)it.next();
1053 if (appContext == showAppContext) {
1054 continue;
1055 }
1056 EventQueue eventQueue = (EventQueue)appContext.get(AppContext.EVENT_QUEUE_KEY);
1057 // it may occur that EDT for appContext hasn't been started yet, so
1058 // we post an empty invocation event to trigger EDT initialization
1059 Runnable createEDT = new Runnable() {
1060 public void run() {};
1061 };
1062 eventQueue.postEvent(new InvocationEvent(this, createEDT));
1063 EventDispatchThread edt = eventQueue.getDispatchThread();
1064 edt.addEventFilter(modalFilter);
1065 }
1066 }
1067
1068 modalityPushed();
1069 try {
1070 EventQueue eventQueue = Toolkit.getDefaultToolkit().getSystemEventQueue();
1071 secondaryLoop = eventQueue.createSecondaryLoop(cond, modalFilter, 0);
1072 if (!secondaryLoop.enter()) {
1073 secondaryLoop = null;
1074 }
1075 } finally {
1076 modalityPopped();
1077 }
1078
1079 // if this dialog is toolkit-modal, its filter must be removed
1080 // from all EDTs (for all AppContexts)
1081 if (modalityType == ModalityType.TOOLKIT_MODAL) {
1082 Iterator it = AppContext.getAppContexts().iterator();
1083 while (it.hasNext()) {
1084 AppContext appContext = (AppContext)it.next();
1085 if (appContext == showAppContext) {
1086 continue;
1087 }
1088 EventQueue eventQueue = (EventQueue)appContext.get(AppContext.EVENT_QUEUE_KEY);
1089 EventDispatchThread edt = eventQueue.getDispatchThread();
1090 edt.removeEventFilter(modalFilter);
1091 }
1092 }
1093
1094 if (windowClosingException != null) {
|
1020 * @see Component#validate
1021 * @see #isModal
1022 * @see Window#setVisible(boolean)
1023 * @deprecated As of JDK version 1.5, replaced by
1024 * {@link #setVisible(boolean) setVisible(boolean)}.
1025 */
1026 @Deprecated
1027 public void show() {
1028 beforeFirstShow = false;
1029 if (!isModal()) {
1030 conditionalShow(null, null);
1031 } else {
1032 AppContext showAppContext = AppContext.getAppContext();
1033
1034 AtomicLong time = new AtomicLong();
1035 Component predictedFocusOwner = null;
1036 try {
1037 predictedFocusOwner = getMostRecentFocusOwner();
1038 if (conditionalShow(predictedFocusOwner, time)) {
1039 modalFilter = ModalEventFilter.createFilterForDialog(this);
1040 final Conditional cond = new Conditional() {
1041 @Override
1042 public boolean evaluate() {
1043 return windowClosingException == null;
1044 }
1045 };
1046
1047 // if this dialog is toolkit-modal, the filter should be added
1048 // to all EDTs (for all AppContexts)
1049 if (modalityType == ModalityType.TOOLKIT_MODAL) {
1050 Iterator it = AppContext.getAppContexts().iterator();
1051 while (it.hasNext()) {
1052 AppContext appContext = (AppContext)it.next();
1053 if (appContext == showAppContext) {
1054 continue;
1055 }
1056 EventQueue eventQueue = (EventQueue)appContext.get(AppContext.EVENT_QUEUE_KEY);
1057 // it may occur that EDT for appContext hasn't been started yet, so
1058 // we post an empty invocation event to trigger EDT initialization
1059 Runnable createEDT = new Runnable() {
1060 public void run() {};
1061 };
1062 eventQueue.postEvent(new InvocationEvent(this, createEDT));
1063 EventDispatchThread edt = eventQueue.getDispatchThread();
1064 edt.addEventFilter(modalFilter);
1065 }
1066 }
1067
1068 modalityPushed();
1069 try {
1070 AccessController.doPrivileged(new PrivilegedAction<Void>() {
1071 public Void run() {
1072 EventQueue eventQueue = Toolkit.getDefaultToolkit().getSystemEventQueue();
1073 secondaryLoop = eventQueue.createSecondaryLoop(cond, modalFilter, 0);
1074 if (!secondaryLoop.enter()) {
1075 secondaryLoop = null;
1076 }
1077 return null;
1078 }
1079 });
1080 } finally {
1081 modalityPopped();
1082 }
1083
1084 // if this dialog is toolkit-modal, its filter must be removed
1085 // from all EDTs (for all AppContexts)
1086 if (modalityType == ModalityType.TOOLKIT_MODAL) {
1087 Iterator it = AppContext.getAppContexts().iterator();
1088 while (it.hasNext()) {
1089 AppContext appContext = (AppContext)it.next();
1090 if (appContext == showAppContext) {
1091 continue;
1092 }
1093 EventQueue eventQueue = (EventQueue)appContext.get(AppContext.EVENT_QUEUE_KEY);
1094 EventDispatchThread edt = eventQueue.getDispatchThread();
1095 edt.removeEventFilter(modalFilter);
1096 }
1097 }
1098
1099 if (windowClosingException != null) {
|