java.awt.event.WindowEvent#WINDOW_CLOSING源码实例Demo

下面列出了java.awt.event.WindowEvent#WINDOW_CLOSING 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: fei_Q   文件: serverMain.java
protected void processWindowEvent(WindowEvent e)
{
	if (e.getID() == WindowEvent.WINDOW_CLOSING)
	{
		String sql_update = "update mainInfo set status = 0;";
		dispose();
		try
		{
			con1.createStatement().execute(sql_update);
		}
		catch (SQLException e1)
		{
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}
		System.exit(0);
	}
	else
	{
		super.processWindowEvent(e);
	}
}
 
源代码2 项目: hottub   文件: JFrame.java
/**
 * Processes window events occurring on this component.
 * Hides the window or disposes of it, as specified by the setting
 * of the <code>defaultCloseOperation</code> property.
 *
 * @param  e  the window event
 * @see    #setDefaultCloseOperation
 * @see    java.awt.Window#processWindowEvent
 */
protected void processWindowEvent(final WindowEvent e) {
    super.processWindowEvent(e);

    if (e.getID() == WindowEvent.WINDOW_CLOSING) {
        switch (defaultCloseOperation) {
            case HIDE_ON_CLOSE:
                setVisible(false);
                break;
            case DISPOSE_ON_CLOSE:
                dispose();
                break;
            case EXIT_ON_CLOSE:
                // This needs to match the checkExit call in
                // setDefaultCloseOperation
                System.exit(0);
                break;
            case DO_NOTHING_ON_CLOSE:
            default:
        }
    }
}
 
源代码3 项目: Bytecoder   文件: JFrame.java
/**
 * Processes window events occurring on this component.
 * Hides the window or disposes of it, as specified by the setting
 * of the <code>defaultCloseOperation</code> property.
 *
 * @param  e  the window event
 * @see    #setDefaultCloseOperation
 * @see    java.awt.Window#processWindowEvent
 */
protected void processWindowEvent(final WindowEvent e) {
    super.processWindowEvent(e);

    if (e.getID() == WindowEvent.WINDOW_CLOSING) {
        switch (defaultCloseOperation) {
            case HIDE_ON_CLOSE:
                setVisible(false);
                break;
            case DISPOSE_ON_CLOSE:
                dispose();
                break;
            case EXIT_ON_CLOSE:
                // This needs to match the checkExit call in
                // setDefaultCloseOperation
                System.exit(0);
                break;
            case DO_NOTHING_ON_CLOSE:
            default:
        }
    }
}
 
源代码4 项目: jdk8u-jdk   文件: JFrame.java
/**
 * Processes window events occurring on this component.
 * Hides the window or disposes of it, as specified by the setting
 * of the <code>defaultCloseOperation</code> property.
 *
 * @param  e  the window event
 * @see    #setDefaultCloseOperation
 * @see    java.awt.Window#processWindowEvent
 */
protected void processWindowEvent(final WindowEvent e) {
    super.processWindowEvent(e);

    if (e.getID() == WindowEvent.WINDOW_CLOSING) {
        switch (defaultCloseOperation) {
            case HIDE_ON_CLOSE:
                setVisible(false);
                break;
            case DISPOSE_ON_CLOSE:
                dispose();
                break;
            case EXIT_ON_CLOSE:
                // This needs to match the checkExit call in
                // setDefaultCloseOperation
                System.exit(0);
                break;
            case DO_NOTHING_ON_CLOSE:
            default:
        }
    }
}
 
源代码5 项目: openjdk-jdk9   文件: JFrame.java
/**
 * Processes window events occurring on this component.
 * Hides the window or disposes of it, as specified by the setting
 * of the <code>defaultCloseOperation</code> property.
 *
 * @param  e  the window event
 * @see    #setDefaultCloseOperation
 * @see    java.awt.Window#processWindowEvent
 */
protected void processWindowEvent(final WindowEvent e) {
    super.processWindowEvent(e);

    if (e.getID() == WindowEvent.WINDOW_CLOSING) {
        switch (defaultCloseOperation) {
            case HIDE_ON_CLOSE:
                setVisible(false);
                break;
            case DISPOSE_ON_CLOSE:
                dispose();
                break;
            case EXIT_ON_CLOSE:
                // This needs to match the checkExit call in
                // setDefaultCloseOperation
                System.exit(0);
                break;
            case DO_NOTHING_ON_CLOSE:
            default:
        }
    }
}
 
源代码6 项目: IBC   文件: SwingUtils.java
static String windowEventToString(int eventID) {
    switch (eventID) { 
        case WindowEvent.WINDOW_ACTIVATED:
            return "Activated";
        case WindowEvent.WINDOW_CLOSED:
            return "Closed";
        case WindowEvent.WINDOW_CLOSING:
            return "Closing";
        case WindowEvent.WINDOW_DEACTIVATED:
            return "Deactivated";
        case WindowEvent.WINDOW_DEICONIFIED:
            return "Deiconified";
        case WindowEvent.WINDOW_GAINED_FOCUS:
            return "Focused";
        case WindowEvent.WINDOW_ICONIFIED:
            return "Iconified";
        case WindowEvent.WINDOW_LOST_FOCUS:
            return "Lost focus";
        case WindowEvent.WINDOW_OPENED:
            return "Opened";
        case WindowEvent.WINDOW_STATE_CHANGED:
            return "State changed";
        default:
            return "???";
    }
}
 
源代码7 项目: openjdk-jdk8u   文件: JFrame.java
/**
 * Processes window events occurring on this component.
 * Hides the window or disposes of it, as specified by the setting
 * of the <code>defaultCloseOperation</code> property.
 *
 * @param  e  the window event
 * @see    #setDefaultCloseOperation
 * @see    java.awt.Window#processWindowEvent
 */
protected void processWindowEvent(final WindowEvent e) {
    super.processWindowEvent(e);

    if (e.getID() == WindowEvent.WINDOW_CLOSING) {
        switch (defaultCloseOperation) {
            case HIDE_ON_CLOSE:
                setVisible(false);
                break;
            case DISPOSE_ON_CLOSE:
                dispose();
                break;
            case EXIT_ON_CLOSE:
                // This needs to match the checkExit call in
                // setDefaultCloseOperation
                System.exit(0);
                break;
            case DO_NOTHING_ON_CLOSE:
            default:
        }
    }
}
 
/**
 * Closes the application specified.
 * @param frame the application to close.
 */
public static void closeApplication(Frame frame) {
    if (null != frame) {
        WindowEvent wev = new WindowEvent(frame, WindowEvent.WINDOW_CLOSING);
        Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(wev);
    }
}
 
源代码9 项目: Bytecoder   文件: Window.java
boolean eventEnabled(AWTEvent e) {
    switch(e.id) {
      case WindowEvent.WINDOW_OPENED:
      case WindowEvent.WINDOW_CLOSING:
      case WindowEvent.WINDOW_CLOSED:
      case WindowEvent.WINDOW_ICONIFIED:
      case WindowEvent.WINDOW_DEICONIFIED:
      case WindowEvent.WINDOW_ACTIVATED:
      case WindowEvent.WINDOW_DEACTIVATED:
        if ((eventMask & AWTEvent.WINDOW_EVENT_MASK) != 0 ||
            windowListener != null) {
            return true;
        }
        return false;
      case WindowEvent.WINDOW_GAINED_FOCUS:
      case WindowEvent.WINDOW_LOST_FOCUS:
        if ((eventMask & AWTEvent.WINDOW_FOCUS_EVENT_MASK) != 0 ||
            windowFocusListener != null) {
            return true;
        }
        return false;
      case WindowEvent.WINDOW_STATE_CHANGED:
        if ((eventMask & AWTEvent.WINDOW_STATE_EVENT_MASK) != 0 ||
            windowStateListener != null) {
            return true;
        }
        return false;
      default:
        break;
    }
    return super.eventEnabled(e);
}
 
源代码10 项目: jts   文件: JTSTestBuilder_AboutBox.java
/**Overridden so we can exit when window is closed*/
protected void processWindowEvent(WindowEvent e) {
    if (e.getID() == WindowEvent.WINDOW_CLOSING) {
        cancel();
    }
    super.processWindowEvent(e);
}
 
public FilterAction acceptEvent(AWTEvent event) {
    if (modalComponent != null) {
        int eventID = event.getID();
        boolean mouseEvent = (eventID >= MouseEvent.MOUSE_FIRST) &&
                             (eventID <= MouseEvent.MOUSE_LAST);
        boolean actionEvent = (eventID >= ActionEvent.ACTION_FIRST) &&
                              (eventID <= ActionEvent.ACTION_LAST);
        boolean windowClosingEvent = (eventID == WindowEvent.WINDOW_CLOSING);
        /*
         * filter out MouseEvent and ActionEvent that's outside
         * the modalComponent hierarchy.
         * KeyEvent is handled by using enqueueKeyEvent
         * in Dialog.show
         */
        if (Component.isInstanceOf(modalComponent, "javax.swing.JInternalFrame")) {
            /*
             * Modal internal frames are handled separately. If event is
             * for some component from another heavyweight than modalComp,
             * it is accepted. If heavyweight is the same - we still accept
             * event and perform further filtering in LightweightDispatcher
             */
            return windowClosingEvent ? FilterAction.REJECT : FilterAction.ACCEPT;
        }
        if (mouseEvent || actionEvent || windowClosingEvent) {
            Object o = event.getSource();
            if (o instanceof sun.awt.ModalExclude) {
                // Exclude this object from modality and
                // continue to pump it's events.
                return FilterAction.ACCEPT;
            } else if (o instanceof Component) {
                Component c = (Component) o;
                // 5.0u3 modal exclusion
                boolean modalExcluded = false;
                if (modalComponent instanceof Container) {
                    while (c != modalComponent && c != null) {
                        if ((c instanceof Window) &&
                            (sun.awt.SunToolkit.isModalExcluded((Window)c))) {
                            // Exclude this window and all its children from
                            //  modality and continue to pump it's events.
                            modalExcluded = true;
                            break;
                        }
                        c = c.getParent();
                    }
                }
                if (!modalExcluded && (c != modalComponent)) {
                    return FilterAction.REJECT;
                }
            }
        }
    }
    return FilterAction.ACCEPT;
}
 
源代码12 项目: jdk8u_jdk   文件: EventDispatchThread.java
public FilterAction acceptEvent(AWTEvent event) {
    if (modalComponent != null) {
        int eventID = event.getID();
        boolean mouseEvent = (eventID >= MouseEvent.MOUSE_FIRST) &&
                             (eventID <= MouseEvent.MOUSE_LAST);
        boolean actionEvent = (eventID >= ActionEvent.ACTION_FIRST) &&
                              (eventID <= ActionEvent.ACTION_LAST);
        boolean windowClosingEvent = (eventID == WindowEvent.WINDOW_CLOSING);
        /*
         * filter out MouseEvent and ActionEvent that's outside
         * the modalComponent hierarchy.
         * KeyEvent is handled by using enqueueKeyEvent
         * in Dialog.show
         */
        if (Component.isInstanceOf(modalComponent, "javax.swing.JInternalFrame")) {
            /*
             * Modal internal frames are handled separately. If event is
             * for some component from another heavyweight than modalComp,
             * it is accepted. If heavyweight is the same - we still accept
             * event and perform further filtering in LightweightDispatcher
             */
            return windowClosingEvent ? FilterAction.REJECT : FilterAction.ACCEPT;
        }
        if (mouseEvent || actionEvent || windowClosingEvent) {
            Object o = event.getSource();
            if (o instanceof sun.awt.ModalExclude) {
                // Exclude this object from modality and
                // continue to pump it's events.
                return FilterAction.ACCEPT;
            } else if (o instanceof Component) {
                Component c = (Component) o;
                // 5.0u3 modal exclusion
                boolean modalExcluded = false;
                if (modalComponent instanceof Container) {
                    while (c != modalComponent && c != null) {
                        if ((c instanceof Window) &&
                            (sun.awt.SunToolkit.isModalExcluded((Window)c))) {
                            // Exclude this window and all its children from
                            //  modality and continue to pump it's events.
                            modalExcluded = true;
                            break;
                        }
                        c = c.getParent();
                    }
                }
                if (!modalExcluded && (c != modalComponent)) {
                    return FilterAction.REJECT;
                }
            }
        }
    }
    return FilterAction.ACCEPT;
}
 
源代码13 项目: TencentKona-8   文件: EventDispatchThread.java
public FilterAction acceptEvent(AWTEvent event) {
    if (modalComponent != null) {
        int eventID = event.getID();
        boolean mouseEvent = (eventID >= MouseEvent.MOUSE_FIRST) &&
                             (eventID <= MouseEvent.MOUSE_LAST);
        boolean actionEvent = (eventID >= ActionEvent.ACTION_FIRST) &&
                              (eventID <= ActionEvent.ACTION_LAST);
        boolean windowClosingEvent = (eventID == WindowEvent.WINDOW_CLOSING);
        /*
         * filter out MouseEvent and ActionEvent that's outside
         * the modalComponent hierarchy.
         * KeyEvent is handled by using enqueueKeyEvent
         * in Dialog.show
         */
        if (Component.isInstanceOf(modalComponent, "javax.swing.JInternalFrame")) {
            /*
             * Modal internal frames are handled separately. If event is
             * for some component from another heavyweight than modalComp,
             * it is accepted. If heavyweight is the same - we still accept
             * event and perform further filtering in LightweightDispatcher
             */
            return windowClosingEvent ? FilterAction.REJECT : FilterAction.ACCEPT;
        }
        if (mouseEvent || actionEvent || windowClosingEvent) {
            Object o = event.getSource();
            if (o instanceof sun.awt.ModalExclude) {
                // Exclude this object from modality and
                // continue to pump it's events.
                return FilterAction.ACCEPT;
            } else if (o instanceof Component) {
                Component c = (Component) o;
                // 5.0u3 modal exclusion
                boolean modalExcluded = false;
                if (modalComponent instanceof Container) {
                    while (c != modalComponent && c != null) {
                        if ((c instanceof Window) &&
                            (sun.awt.SunToolkit.isModalExcluded((Window)c))) {
                            // Exclude this window and all its children from
                            //  modality and continue to pump it's events.
                            modalExcluded = true;
                            break;
                        }
                        c = c.getParent();
                    }
                }
                if (!modalExcluded && (c != modalComponent)) {
                    return FilterAction.REJECT;
                }
            }
        }
    }
    return FilterAction.ACCEPT;
}
 
源代码14 项目: openjdk-8-source   文件: EventDispatchThread.java
public FilterAction acceptEvent(AWTEvent event) {
    if (modalComponent != null) {
        int eventID = event.getID();
        boolean mouseEvent = (eventID >= MouseEvent.MOUSE_FIRST) &&
                             (eventID <= MouseEvent.MOUSE_LAST);
        boolean actionEvent = (eventID >= ActionEvent.ACTION_FIRST) &&
                              (eventID <= ActionEvent.ACTION_LAST);
        boolean windowClosingEvent = (eventID == WindowEvent.WINDOW_CLOSING);
        /*
         * filter out MouseEvent and ActionEvent that's outside
         * the modalComponent hierarchy.
         * KeyEvent is handled by using enqueueKeyEvent
         * in Dialog.show
         */
        if (Component.isInstanceOf(modalComponent, "javax.swing.JInternalFrame")) {
            /*
             * Modal internal frames are handled separately. If event is
             * for some component from another heavyweight than modalComp,
             * it is accepted. If heavyweight is the same - we still accept
             * event and perform further filtering in LightweightDispatcher
             */
            return windowClosingEvent ? FilterAction.REJECT : FilterAction.ACCEPT;
        }
        if (mouseEvent || actionEvent || windowClosingEvent) {
            Object o = event.getSource();
            if (o instanceof sun.awt.ModalExclude) {
                // Exclude this object from modality and
                // continue to pump it's events.
                return FilterAction.ACCEPT;
            } else if (o instanceof Component) {
                Component c = (Component) o;
                // 5.0u3 modal exclusion
                boolean modalExcluded = false;
                if (modalComponent instanceof Container) {
                    while (c != modalComponent && c != null) {
                        if ((c instanceof Window) &&
                            (sun.awt.SunToolkit.isModalExcluded((Window)c))) {
                            // Exclude this window and all its children from
                            //  modality and continue to pump it's events.
                            modalExcluded = true;
                            break;
                        }
                        c = c.getParent();
                    }
                }
                if (!modalExcluded && (c != modalComponent)) {
                    return FilterAction.REJECT;
                }
            }
        }
    }
    return FilterAction.ACCEPT;
}
 
源代码15 项目: JDKSourceCode1.8   文件: EventDispatchThread.java
public FilterAction acceptEvent(AWTEvent event) {
    if (modalComponent != null) {
        int eventID = event.getID();
        boolean mouseEvent = (eventID >= MouseEvent.MOUSE_FIRST) &&
                             (eventID <= MouseEvent.MOUSE_LAST);
        boolean actionEvent = (eventID >= ActionEvent.ACTION_FIRST) &&
                              (eventID <= ActionEvent.ACTION_LAST);
        boolean windowClosingEvent = (eventID == WindowEvent.WINDOW_CLOSING);
        /*
         * filter out MouseEvent and ActionEvent that's outside
         * the modalComponent hierarchy.
         * KeyEvent is handled by using enqueueKeyEvent
         * in Dialog.show
         */
        if (Component.isInstanceOf(modalComponent, "javax.swing.JInternalFrame")) {
            /*
             * Modal internal frames are handled separately. If event is
             * for some component from another heavyweight than modalComp,
             * it is accepted. If heavyweight is the same - we still accept
             * event and perform further filtering in LightweightDispatcher
             */
            return windowClosingEvent ? FilterAction.REJECT : FilterAction.ACCEPT;
        }
        if (mouseEvent || actionEvent || windowClosingEvent) {
            Object o = event.getSource();
            if (o instanceof sun.awt.ModalExclude) {
                // Exclude this object from modality and
                // continue to pump it's events.
                return FilterAction.ACCEPT;
            } else if (o instanceof Component) {
                Component c = (Component) o;
                // 5.0u3 modal exclusion
                boolean modalExcluded = false;
                if (modalComponent instanceof Container) {
                    while (c != modalComponent && c != null) {
                        if ((c instanceof Window) &&
                            (sun.awt.SunToolkit.isModalExcluded((Window)c))) {
                            // Exclude this window and all its children from
                            //  modality and continue to pump it's events.
                            modalExcluded = true;
                            break;
                        }
                        c = c.getParent();
                    }
                }
                if (!modalExcluded && (c != modalComponent)) {
                    return FilterAction.REJECT;
                }
            }
        }
    }
    return FilterAction.ACCEPT;
}
 
源代码16 项目: jdk8u-jdk   文件: EventDispatchThread.java
public FilterAction acceptEvent(AWTEvent event) {
    if (modalComponent != null) {
        int eventID = event.getID();
        boolean mouseEvent = (eventID >= MouseEvent.MOUSE_FIRST) &&
                             (eventID <= MouseEvent.MOUSE_LAST);
        boolean actionEvent = (eventID >= ActionEvent.ACTION_FIRST) &&
                              (eventID <= ActionEvent.ACTION_LAST);
        boolean windowClosingEvent = (eventID == WindowEvent.WINDOW_CLOSING);
        /*
         * filter out MouseEvent and ActionEvent that's outside
         * the modalComponent hierarchy.
         * KeyEvent is handled by using enqueueKeyEvent
         * in Dialog.show
         */
        if (Component.isInstanceOf(modalComponent, "javax.swing.JInternalFrame")) {
            /*
             * Modal internal frames are handled separately. If event is
             * for some component from another heavyweight than modalComp,
             * it is accepted. If heavyweight is the same - we still accept
             * event and perform further filtering in LightweightDispatcher
             */
            return windowClosingEvent ? FilterAction.REJECT : FilterAction.ACCEPT;
        }
        if (mouseEvent || actionEvent || windowClosingEvent) {
            Object o = event.getSource();
            if (o instanceof sun.awt.ModalExclude) {
                // Exclude this object from modality and
                // continue to pump it's events.
                return FilterAction.ACCEPT;
            } else if (o instanceof Component) {
                Component c = (Component) o;
                // 5.0u3 modal exclusion
                boolean modalExcluded = false;
                if (modalComponent instanceof Container) {
                    while (c != modalComponent && c != null) {
                        if ((c instanceof Window) &&
                            (sun.awt.SunToolkit.isModalExcluded((Window)c))) {
                            // Exclude this window and all its children from
                            //  modality and continue to pump it's events.
                            modalExcluded = true;
                            break;
                        }
                        c = c.getParent();
                    }
                }
                if (!modalExcluded && (c != modalComponent)) {
                    return FilterAction.REJECT;
                }
            }
        }
    }
    return FilterAction.ACCEPT;
}
 
源代码17 项目: Launcher   文件: NativeJVMHalt.java
public WindowShutdown() {
    super();
    super.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    super.processWindowEvent(new WindowEvent(this, WindowEvent.WINDOW_CLOSING));
}
 
源代码18 项目: IBC   文件: TradesFrameHandler.java
@Override
public void handleWindow(final Window window, int eventID) {
    if (!firstTradesWindowOpened) {
        showAllTrades = Settings.settings().getBoolean("ShowAllTrades", false);
    }
    if (!showAllTrades) {
        firstTradesWindowOpened = true;
        return;
    }
    if (eventID == WindowEvent.WINDOW_OPENED) {
        if (findCheckBox(window, "Sun") != null) {
            Utils.logToConsole("Setting trades log to show all trades");
            // TWS versions before 955
            SwingUtils.setCheckBoxSelected(window, "Sun", true);
            SwingUtils.setCheckBoxSelected(window, "Mon", true);
            SwingUtils.setCheckBoxSelected(window, "Tue", true);
            SwingUtils.setCheckBoxSelected(window, "Wed", true);
            SwingUtils.setCheckBoxSelected(window, "Thu", true);
            SwingUtils.setCheckBoxSelected(window, "Fri", true);
            SwingUtils.setCheckBoxSelected(window, "Sat", true);
            SwingUtils.setCheckBoxSelected(window, "All", true);

            monitorAllTradesCheckbox(window, "All");

            if (! firstTradesWindowOpened) {
                if (Settings.settings().getBoolean("MinimizeMainWindow", false)) {
                    ((JFrame) window).setExtendedState(java.awt.Frame.ICONIFIED);
                }
            }
        } else {
            Utils.logToConsole("Can't set trades log to show all trades with this TWS version: user must do this");
            /*
             * For TWS 955 onwards, IB have replaced the row of daily 
             * checkboxes with what appears visually to be a combo box:
             * it is indeed derived from a JComboBox, but setting the
             * selected item to 'Last 7 Days' doesn't have the desired
             * effect.
             * 
             * At present I don't see a way of getting round this, but 
             * the setting chosen by the user can now be persisted
             * between sessions, so there is really no longer a need for
             * 'ShowAllTrades'.
             * 
             */
            
            showAllTrades = false;
            ((JFrame) window).dispose();
        }

        firstTradesWindowOpened = true;

    } else if (eventID == WindowEvent.WINDOW_CLOSING) {
        Utils.logToConsole("User closing trades log");
    } else if (eventID == WindowEvent.WINDOW_CLOSED) {
        if (showAllTrades) {
            Utils.logToConsole("Trades log closed by user - recreating");
            Utils.showTradesLogWindow();
        }
    }

}
 
源代码19 项目: openjdk-jdk8u   文件: EventDispatchThread.java
public FilterAction acceptEvent(AWTEvent event) {
    if (modalComponent != null) {
        int eventID = event.getID();
        boolean mouseEvent = (eventID >= MouseEvent.MOUSE_FIRST) &&
                             (eventID <= MouseEvent.MOUSE_LAST);
        boolean actionEvent = (eventID >= ActionEvent.ACTION_FIRST) &&
                              (eventID <= ActionEvent.ACTION_LAST);
        boolean windowClosingEvent = (eventID == WindowEvent.WINDOW_CLOSING);
        /*
         * filter out MouseEvent and ActionEvent that's outside
         * the modalComponent hierarchy.
         * KeyEvent is handled by using enqueueKeyEvent
         * in Dialog.show
         */
        if (Component.isInstanceOf(modalComponent, "javax.swing.JInternalFrame")) {
            /*
             * Modal internal frames are handled separately. If event is
             * for some component from another heavyweight than modalComp,
             * it is accepted. If heavyweight is the same - we still accept
             * event and perform further filtering in LightweightDispatcher
             */
            return windowClosingEvent ? FilterAction.REJECT : FilterAction.ACCEPT;
        }
        if (mouseEvent || actionEvent || windowClosingEvent) {
            Object o = event.getSource();
            if (o instanceof sun.awt.ModalExclude) {
                // Exclude this object from modality and
                // continue to pump it's events.
                return FilterAction.ACCEPT;
            } else if (o instanceof Component) {
                Component c = (Component) o;
                // 5.0u3 modal exclusion
                boolean modalExcluded = false;
                if (modalComponent instanceof Container) {
                    while (c != modalComponent && c != null) {
                        if ((c instanceof Window) &&
                            (sun.awt.SunToolkit.isModalExcluded((Window)c))) {
                            // Exclude this window and all its children from
                            //  modality and continue to pump it's events.
                            modalExcluded = true;
                            break;
                        }
                        c = c.getParent();
                    }
                }
                if (!modalExcluded && (c != modalComponent)) {
                    return FilterAction.REJECT;
                }
            }
        }
    }
    return FilterAction.ACCEPT;
}
 
源代码20 项目: jdk8u-jdk   文件: EventDispatchThread.java
public FilterAction acceptEvent(AWTEvent event) {
    if (modalComponent != null) {
        int eventID = event.getID();
        boolean mouseEvent = (eventID >= MouseEvent.MOUSE_FIRST) &&
                             (eventID <= MouseEvent.MOUSE_LAST);
        boolean actionEvent = (eventID >= ActionEvent.ACTION_FIRST) &&
                              (eventID <= ActionEvent.ACTION_LAST);
        boolean windowClosingEvent = (eventID == WindowEvent.WINDOW_CLOSING);
        /*
         * filter out MouseEvent and ActionEvent that's outside
         * the modalComponent hierarchy.
         * KeyEvent is handled by using enqueueKeyEvent
         * in Dialog.show
         */
        if (Component.isInstanceOf(modalComponent, "javax.swing.JInternalFrame")) {
            /*
             * Modal internal frames are handled separately. If event is
             * for some component from another heavyweight than modalComp,
             * it is accepted. If heavyweight is the same - we still accept
             * event and perform further filtering in LightweightDispatcher
             */
            return windowClosingEvent ? FilterAction.REJECT : FilterAction.ACCEPT;
        }
        if (mouseEvent || actionEvent || windowClosingEvent) {
            Object o = event.getSource();
            if (o instanceof sun.awt.ModalExclude) {
                // Exclude this object from modality and
                // continue to pump it's events.
                return FilterAction.ACCEPT;
            } else if (o instanceof Component) {
                Component c = (Component) o;
                // 5.0u3 modal exclusion
                boolean modalExcluded = false;
                if (modalComponent instanceof Container) {
                    while (c != modalComponent && c != null) {
                        if ((c instanceof Window) &&
                            (sun.awt.SunToolkit.isModalExcluded((Window)c))) {
                            // Exclude this window and all its children from
                            //  modality and continue to pump it's events.
                            modalExcluded = true;
                            break;
                        }
                        c = c.getParent();
                    }
                }
                if (!modalExcluded && (c != modalComponent)) {
                    return FilterAction.REJECT;
                }
            }
        }
    }
    return FilterAction.ACCEPT;
}