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

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

源代码1 项目: IBC   文件: TwsListener.java
@Override
public void eventDispatched(AWTEvent event) {
    int eventID = event.getID();

    Window window =((WindowEvent) event).getWindow();

    if (eventID == WindowEvent.WINDOW_OPENED ||
            eventID == WindowEvent.WINDOW_ACTIVATED ||
            eventID == WindowEvent.WINDOW_CLOSING ||
            eventID == WindowEvent.WINDOW_CLOSED || 
            eventID == WindowEvent.WINDOW_ICONIFIED ||
            eventID == WindowEvent.WINDOW_DEICONIFIED) {
        logWindow(window, eventID);
    }

    for (WindowHandler wh : windowHandlers) {
        if (wh.filterEvent(window, eventID) && wh.recogniseWindow(window))  {
            wh.handleWindow(window, eventID);
            break;
        }
    }

}
 
源代码2 项目: IBC   文件: SplashFrameHandler.java
@Override
public boolean filterEvent(Window window, int eventId) {
    /*
     * Note that we are only interested in the closing of the gateway splash
     * frame, because that indicates that the gateway is now in a position to
     * start handling menu commands.
     * 
     * Note also that the splash frame's window title is repeatedly changed during 
     * gateway initialisation, and it's only the last title value that we use for 
     * recognising it
     */
    switch (eventId) {
        case WindowEvent.WINDOW_CLOSED:
            return true;
        default:
            return false;
    }
}
 
源代码3 项目: 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 "???";
    }
}
 
源代码4 项目: Bytecoder   文件: Window.java
/**
 * Processes events on this window. If the event is an
 * {@code WindowEvent}, it invokes the
 * {@code processWindowEvent} method, else it invokes its
 * superclass's {@code processEvent}.
 * <p>Note that if the event parameter is {@code null}
 * the behavior is unspecified and may result in an
 * exception.
 *
 * @param e the event
 */
protected void processEvent(AWTEvent e) {
    if (e instanceof WindowEvent) {
        switch (e.getID()) {
            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:
                processWindowEvent((WindowEvent)e);
                break;
            case WindowEvent.WINDOW_GAINED_FOCUS:
            case WindowEvent.WINDOW_LOST_FOCUS:
                processWindowFocusEvent((WindowEvent)e);
                break;
            case WindowEvent.WINDOW_STATE_CHANGED:
                processWindowStateEvent((WindowEvent)e);
                break;
        }
        return;
    }
    super.processEvent(e);
}
 
源代码5 项目: ib-controller   文件: TwsListener.java
@Override
public void eventDispatched(AWTEvent event) {
    int eventID = event.getID();

    Window window =((WindowEvent) event).getWindow();

    if (eventID == WindowEvent.WINDOW_OPENED ||
            eventID == WindowEvent.WINDOW_ACTIVATED ||
            eventID == WindowEvent.WINDOW_CLOSING ||
            eventID == WindowEvent.WINDOW_CLOSED) {
        logWindow(window, eventID);
    }

    for (WindowHandler wh : windowHandlers) {
        if (wh.filterEvent(window, eventID) && wh.recogniseWindow(window))  {
            wh.handleWindow(window, eventID);
            break;
        }
    }

}
 
源代码6 项目: ib-controller   文件: SplashFrameHandler.java
@Override
public boolean filterEvent(Window window, int eventId) {
    /*
     * Note that we are only interested in the closing of the gateway splash
     * frame, because that indicates that the gateway is now in a position to
     * start handling menu commands.
     * 
     * Note also that the splash frame's window title is repeatedly changed during 
     * gateway initialisation, and it's only the last title value that we use for 
     * recognising it
     */
    switch (eventId) {
        case WindowEvent.WINDOW_CLOSED:
            return true;
        default:
            return false;
    }
}
 
源代码7 项目: ib-controller   文件: 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 "Deiconfied";
        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 "???";
    }
}
 
源代码8 项目: IBC   文件: GlobalConfigurationDialogHandler.java
@Override
public boolean filterEvent(Window window, int eventId) {
    switch (eventId) {
        case WindowEvent.WINDOW_OPENED:
            return true;
        case WindowEvent.WINDOW_CLOSED:
            return true;
        default:
            return false;
    }
}
 
源代码9 项目: IBC   文件: GlobalConfigurationDialogHandler.java
@Override
public void handleWindow(final Window window, int eventId) {
    switch (eventId) {
        case WindowEvent.WINDOW_OPENED:
            ConfigDialogManager.configDialogManager().setConfigDialog((JDialog) window);
            break;
        case WindowEvent.WINDOW_CLOSED:
            ConfigDialogManager.configDialogManager().clearConfigDialog();
    }
}
 
源代码10 项目: IBC   文件: TradesFrameHandler.java
@Override
public boolean filterEvent(Window window, int eventId) {
    switch (eventId) {
        case WindowEvent.WINDOW_OPENED:
        case WindowEvent.WINDOW_CLOSING:
        case WindowEvent.WINDOW_CLOSED:
            return true;
        default:
            return false;
    }
}
 
源代码11 项目: 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);
}
 
源代码12 项目: Bytecoder   文件: Window.java
/**
 * Processes window events occurring on this window by
 * dispatching them to any registered WindowListener objects.
 * NOTE: This method will not be called unless window events
 * are enabled for this component; this happens when one of the
 * following occurs:
 * <ul>
 * <li>A WindowListener object is registered via
 *     {@code addWindowListener}
 * <li>Window events are enabled via {@code enableEvents}
 * </ul>
 * <p>Note that if the event parameter is {@code null}
 * the behavior is unspecified and may result in an
 * exception.
 *
 * @param e the window event
 * @see Component#enableEvents
 */
protected void processWindowEvent(WindowEvent e) {
    WindowListener listener = windowListener;
    if (listener != null) {
        switch(e.getID()) {
            case WindowEvent.WINDOW_OPENED:
                listener.windowOpened(e);
                break;
            case WindowEvent.WINDOW_CLOSING:
                listener.windowClosing(e);
                break;
            case WindowEvent.WINDOW_CLOSED:
                listener.windowClosed(e);
                break;
            case WindowEvent.WINDOW_ICONIFIED:
                listener.windowIconified(e);
                break;
            case WindowEvent.WINDOW_DEICONIFIED:
                listener.windowDeiconified(e);
                break;
            case WindowEvent.WINDOW_ACTIVATED:
                listener.windowActivated(e);
                break;
            case WindowEvent.WINDOW_DEACTIVATED:
                listener.windowDeactivated(e);
                break;
            default:
                break;
        }
    }
}
 
@Override
public boolean filterEvent(Window window, int eventId) {
    switch (eventId) {
        case WindowEvent.WINDOW_OPENED:
            return true;
        case WindowEvent.WINDOW_CLOSED:
            return true;
        default:
            return false;
    }
}
 
@Override
public void handleWindow(final Window window, int eventId) {
    switch (eventId) {
        case WindowEvent.WINDOW_OPENED:
            ConfigDialogManager.configDialogManager().setConfigDialog((JDialog) window);
            break;
        case WindowEvent.WINDOW_CLOSED:
            ConfigDialogManager.configDialogManager().clearConfigDialog();
    }
}
 
源代码15 项目: ib-controller   文件: TradesFrameHandler.java
@Override
public boolean filterEvent(Window window, int eventId) {
    switch (eventId) {
        case WindowEvent.WINDOW_OPENED:
        case WindowEvent.WINDOW_CLOSING:
        case WindowEvent.WINDOW_CLOSED:
            return true;
        default:
            return false;
    }
}
 
源代码16 项目: consulo   文件: DesktopWindowWatcher.java
final void dispatchComponentEvent(final ComponentEvent e) {
  final int id = e.getID();
  if (WindowEvent.WINDOW_CLOSED == id || (ComponentEvent.COMPONENT_HIDDEN == id && e.getSource() instanceof Window)) {
    dispatchHiddenOrClosed(TargetAWT.from((Window)e.getSource()));
  }
  // Clear obsolete reference on root frame
  if (WindowEvent.WINDOW_CLOSED == id) {
    final Window window = (Window)e.getSource();

    if (JOptionPane.getRootFrame() == window) {
      JOptionPane.setRootFrame(null);
    }
  }
}
 
源代码17 项目: 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();
        }
    }

}
 
源代码18 项目: ib-controller   文件: 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();
        }
    }

}