Java Code Examples for java.awt.event.WindowEvent#WINDOW_STATE_CHANGED

The following examples show how to use java.awt.event.WindowEvent#WINDOW_STATE_CHANGED . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SwingUtils.java    From IBC with GNU General Public License v3.0 6 votes vote down vote up
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 "???";
    }
}
 
Example 2
Source File: Window.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
/**
 * 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);
}
 
Example 3
Source File: SwingUtils.java    From ib-controller with GNU General Public License v3.0 6 votes vote down vote up
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 "???";
    }
}
 
Example 4
Source File: Window.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example 5
Source File: Toolkit.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
public void eventDispatched(AWTEvent event) {
    long eventBit = 0; // Used to save the bit of the event type.
    if (((eventBit = eventMask & AWTEvent.COMPONENT_EVENT_MASK) != 0 &&
         event.id >= ComponentEvent.COMPONENT_FIRST &&
         event.id <= ComponentEvent.COMPONENT_LAST)
     || ((eventBit = eventMask & AWTEvent.CONTAINER_EVENT_MASK) != 0 &&
         event.id >= ContainerEvent.CONTAINER_FIRST &&
         event.id <= ContainerEvent.CONTAINER_LAST)
     || ((eventBit = eventMask & AWTEvent.FOCUS_EVENT_MASK) != 0 &&
         event.id >= FocusEvent.FOCUS_FIRST &&
         event.id <= FocusEvent.FOCUS_LAST)
     || ((eventBit = eventMask & AWTEvent.KEY_EVENT_MASK) != 0 &&
         event.id >= KeyEvent.KEY_FIRST &&
         event.id <= KeyEvent.KEY_LAST)
     || ((eventBit = eventMask & AWTEvent.MOUSE_WHEEL_EVENT_MASK) != 0 &&
         event.id == MouseEvent.MOUSE_WHEEL)
     || ((eventBit = eventMask & AWTEvent.MOUSE_MOTION_EVENT_MASK) != 0 &&
         (event.id == MouseEvent.MOUSE_MOVED ||
          event.id == MouseEvent.MOUSE_DRAGGED))
     || ((eventBit = eventMask & AWTEvent.MOUSE_EVENT_MASK) != 0 &&
         event.id != MouseEvent.MOUSE_MOVED &&
         event.id != MouseEvent.MOUSE_DRAGGED &&
         event.id != MouseEvent.MOUSE_WHEEL &&
         event.id >= MouseEvent.MOUSE_FIRST &&
         event.id <= MouseEvent.MOUSE_LAST)
     || ((eventBit = eventMask & AWTEvent.WINDOW_EVENT_MASK) != 0 &&
         (event.id >= WindowEvent.WINDOW_FIRST &&
         event.id <= WindowEvent.WINDOW_LAST))
     || ((eventBit = eventMask & AWTEvent.ACTION_EVENT_MASK) != 0 &&
         event.id >= ActionEvent.ACTION_FIRST &&
         event.id <= ActionEvent.ACTION_LAST)
     || ((eventBit = eventMask & AWTEvent.ADJUSTMENT_EVENT_MASK) != 0 &&
         event.id >= AdjustmentEvent.ADJUSTMENT_FIRST &&
         event.id <= AdjustmentEvent.ADJUSTMENT_LAST)
     || ((eventBit = eventMask & AWTEvent.ITEM_EVENT_MASK) != 0 &&
         event.id >= ItemEvent.ITEM_FIRST &&
         event.id <= ItemEvent.ITEM_LAST)
     || ((eventBit = eventMask & AWTEvent.TEXT_EVENT_MASK) != 0 &&
         event.id >= TextEvent.TEXT_FIRST &&
         event.id <= TextEvent.TEXT_LAST)
     || ((eventBit = eventMask & AWTEvent.INPUT_METHOD_EVENT_MASK) != 0 &&
         event.id >= InputMethodEvent.INPUT_METHOD_FIRST &&
         event.id <= InputMethodEvent.INPUT_METHOD_LAST)
     || ((eventBit = eventMask & AWTEvent.PAINT_EVENT_MASK) != 0 &&
         event.id >= PaintEvent.PAINT_FIRST &&
         event.id <= PaintEvent.PAINT_LAST)
     || ((eventBit = eventMask & AWTEvent.INVOCATION_EVENT_MASK) != 0 &&
         event.id >= InvocationEvent.INVOCATION_FIRST &&
         event.id <= InvocationEvent.INVOCATION_LAST)
     || ((eventBit = eventMask & AWTEvent.HIERARCHY_EVENT_MASK) != 0 &&
         event.id == HierarchyEvent.HIERARCHY_CHANGED)
     || ((eventBit = eventMask & AWTEvent.HIERARCHY_BOUNDS_EVENT_MASK) != 0 &&
         (event.id == HierarchyEvent.ANCESTOR_MOVED ||
          event.id == HierarchyEvent.ANCESTOR_RESIZED))
     || ((eventBit = eventMask & AWTEvent.WINDOW_STATE_EVENT_MASK) != 0 &&
         event.id == WindowEvent.WINDOW_STATE_CHANGED)
     || ((eventBit = eventMask & AWTEvent.WINDOW_FOCUS_EVENT_MASK) != 0 &&
         (event.id == WindowEvent.WINDOW_GAINED_FOCUS ||
          event.id == WindowEvent.WINDOW_LOST_FOCUS))
        || ((eventBit = eventMask & sun.awt.SunToolkit.GRAB_EVENT_MASK) != 0 &&
            (event instanceof sun.awt.UngrabEvent))) {
        // Get the index of the call count for this event type.
        // Instead of using Math.log(...) we will calculate it with
        // bit shifts. That's what previous implementation looked like:
        //
        // int ci = (int) (Math.log(eventBit)/Math.log(2));
        int ci = 0;
        for (long eMask = eventBit; eMask != 0; eMask >>>= 1, ci++) {
        }
        ci--;
        // Call the listener as many times as it was added for this
        // event type.
        for (int i=0; i<calls[ci]; i++) {
            listener.eventDispatched(event);
        }
    }
}
 
Example 6
Source File: Window.java    From Bytecoder with Apache License 2.0 3 votes vote down vote up
/**
 * Processes window state event occurring on this window by
 * dispatching them to any registered {@code WindowStateListener}
 * objects.
 * NOTE: this method will not be called unless window state events
 * are enabled for this window.  This happens when one of the
 * following occurs:
 * <ul>
 * <li>a {@code WindowStateListener} is registered via
 *    {@code addWindowStateListener}
 * <li>window state 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 state event
 * @see java.awt.Component#enableEvents
 * @since 1.4
 */
protected void processWindowStateEvent(WindowEvent e) {
    WindowStateListener listener = windowStateListener;
    if (listener != null) {
        switch (e.getID()) {
            case WindowEvent.WINDOW_STATE_CHANGED:
                listener.windowStateChanged(e);
                break;
            default:
                break;
        }
    }
}