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

The following examples show how to use java.awt.event.WindowEvent#WINDOW_ACTIVATED . 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: TwsListener.java    From ib-controller with GNU General Public License v3.0 6 votes vote down vote up
private void logWindow(Window window, int eventID) {
    String event = SwingUtils.windowEventToString(eventID);

    if (window instanceof JFrame) {
        Utils.logToConsole("detected frame entitled: " + ((JFrame) window).getTitle() + "; event=" + event);
    } else if (window instanceof JDialog) {
        Utils.logToConsole("detected dialog entitled: " + ((JDialog) window).getTitle() + "; event=" + event);
    } else {
        Utils.logToConsole("detected window: type=" + window.getClass().getName() + "; event=" + event);
    }
    
    if ((eventID == WindowEvent.WINDOW_OPENED && (logComponents.equals("open") || logComponents.equals("activate")))
        ||
        (eventID == WindowEvent.WINDOW_ACTIVATED && logComponents.equals("activate")))
    {
        Utils.logRawToConsole(SwingUtils.getWindowStructure(window));
    }
}
 
Example 2
Source File: TwsListener.java    From ib-controller with GNU General Public License v3.0 6 votes vote down vote up
@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;
        }
    }

}
 
Example 3
Source File: TwsListener.java    From IBC with GNU General Public License v3.0 6 votes vote down vote up
private void logWindow(Window window, int eventID) {
    String event = SwingUtils.windowEventToString(eventID);

    if (window instanceof JFrame) {
        Utils.logToConsole("detected frame entitled: " + ((JFrame) window).getTitle() + "; event=" + event);
    } else if (window instanceof JDialog) {
        Utils.logToConsole("detected dialog entitled: " + ((JDialog) window).getTitle() + "; event=" + event);
    } else {
        Utils.logToConsole("detected window: type=" + window.getClass().getName() + "; event=" + event);
    }
    
    if ((eventID == WindowEvent.WINDOW_OPENED && (logComponents.equals("open") || logComponents.equals("activate")))
        ||
        (eventID == WindowEvent.WINDOW_ACTIVATED && logComponents.equals("activate")))
    {
        Utils.logRawToConsole(SwingUtils.getWindowStructure(window));
    }
}
 
Example 4
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 5
Source File: DefaultWindowController.java    From lnk2pwn with MIT License 6 votes vote down vote up
@Override
public void eventDispatched(AWTEvent event) {
    if (event instanceof WindowEvent) {
        WindowEvent windowEvent = (WindowEvent) event;
        
        switch(windowEvent.getID())
        {
            case WindowEvent.WINDOW_ACTIVATED:
                window = windowEvent.getWindow();
                break;
                
            case WindowEvent.WINDOW_DEACTIVATED:
                window = null;
                break;
                
            default:
                break;
        }
        
    }
}
 
Example 6
Source File: NewerVersionDialogHandler.java    From IBC with GNU General Public License v3.0 5 votes vote down vote up
public boolean filterEvent(Window window, int eventId) {
    switch (eventId) {
        case WindowEvent.WINDOW_OPENED:
        case WindowEvent.WINDOW_ACTIVATED:
            return true;
        default:
            return false;
    }
}
 
Example 7
Source File: NewerVersionFrameHandler.java    From ib-controller with GNU General Public License v3.0 5 votes vote down vote up
public boolean filterEvent(Window window, int eventId) {
    switch (eventId) {
        case WindowEvent.WINDOW_OPENED:
        case WindowEvent.WINDOW_ACTIVATED:
            return true;
        default:
            return false;
    }
}
 
Example 8
Source File: MainWindow.java    From FoxTelem with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void windowStateChanged(WindowEvent e) {
	if (e.getNewState() == WindowEvent.WINDOW_LOST_FOCUS) {
		//e.getWindow().setVisible(false);
		Log.println("LOST FOCUS");
	}
	if (e.getNewState() == WindowEvent.WINDOW_ACTIVATED) {
		//e.getWindow().setVisible(false);
		Log.println("ACTIVATED");
	}
	if (e.getNewState() == WindowEvent.WINDOW_GAINED_FOCUS) {
		//e.getWindow().setVisible(false);
		Log.println("GOT FOCUS");
	}
}
 
Example 9
Source File: Window.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
/**
 * 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;
        }
    }
}
 
Example 10
Source File: ExitSessionFrameHandler.java    From ib-controller with GNU General Public License v3.0 5 votes vote down vote up
public boolean filterEvent(Window window, int eventId) {
    switch (eventId) {
        case WindowEvent.WINDOW_OPENED:
        case WindowEvent.WINDOW_ACTIVATED:
            return true;
        default:
            return false;
    }
}
 
Example 11
Source File: TipOfTheDayDialogHandler.java    From ib-controller with GNU General Public License v3.0 5 votes vote down vote up
public boolean filterEvent(Window window, int eventId) {
    switch (eventId) {
        case WindowEvent.WINDOW_OPENED:
        case WindowEvent.WINDOW_ACTIVATED:
            return true;
        default:
            return false;
    }
}
 
Example 12
Source File: NbClipboard.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public void eventDispatched(AWTEvent ev) {
    if (!(ev instanceof WindowEvent))
        return;

    if (ev.getID() == WindowEvent.WINDOW_DEACTIVATED) {
        lastWindowDeactivated = System.currentTimeMillis();
        lastWindowDeactivatedSource = new WeakReference<Object>(ev.getSource());
        anyWindowIsActivated = false;
        if( Utilities.isWindows() ) {
            //#247585 - even listening to clipboard changes when the window isn't active 
            //may throw a MS Windows error as the 'clipboard copy' action doesn't have enough time to finish
            systemClipboard.removeFlavorListener(this);
        }
    }
    if (ev.getID() == WindowEvent.WINDOW_ACTIVATED) {
        if( Utilities.isWindows() ) {
            systemClipboard.addFlavorListener(this);
        }
        anyWindowIsActivated = true;
        if (System.currentTimeMillis() - lastWindowDeactivated < 100 &&
            ev.getSource() == lastWindowDeactivatedSource.get()) {
            activateWindowHack (false);
        }
        if (log.isLoggable (Level.FINE)) {
            log.log (Level.FINE, "window activated scheduling update"); // NOI18N
        }
        scheduleGetFromSystemClipboard(true);
    }
}
 
Example 13
Source File: NewerVersionDialogHandler.java    From ib-controller with GNU General Public License v3.0 5 votes vote down vote up
public boolean filterEvent(Window window, int eventId) {
    switch (eventId) {
        case WindowEvent.WINDOW_OPENED:
        case WindowEvent.WINDOW_ACTIVATED:
            return true;
        default:
            return false;
    }
}
 
Example 14
Source File: ExitSessionFrameHandler.java    From IBC with GNU General Public License v3.0 5 votes vote down vote up
public boolean filterEvent(Window window, int eventId) {
    switch (eventId) {
        case WindowEvent.WINDOW_OPENED:
        case WindowEvent.WINDOW_ACTIVATED:
            return true;
        default:
            return false;
    }
}
 
Example 15
Source File: PasswordExpiryWarningFrameHandler.java    From ib-controller with GNU General Public License v3.0 5 votes vote down vote up
public boolean filterEvent(Window window, int eventId) {
    switch (eventId) {
        case WindowEvent.WINDOW_OPENED:
        case WindowEvent.WINDOW_ACTIVATED:
            return true;
        default:
            return false;
    }
}
 
Example 16
Source File: PasswordExpiryWarningFrameHandler.java    From IBC with GNU General Public License v3.0 5 votes vote down vote up
public boolean filterEvent(Window window, int eventId) {
    switch (eventId) {
        case WindowEvent.WINDOW_OPENED:
        case WindowEvent.WINDOW_ACTIVATED:
            return true;
        default:
            return false;
    }
}
 
Example 17
Source File: NSEComplianceFrameHandler.java    From IBC with GNU General Public License v3.0 5 votes vote down vote up
public boolean filterEvent(Window window, int eventId) {
    switch (eventId) {
        case WindowEvent.WINDOW_OPENED:
        case WindowEvent.WINDOW_ACTIVATED:
            return true;
        default:
            return false;
    }
}
 
Example 18
Source File: NotCurrentlyAvailableDialogHandler.java    From ib-controller with GNU General Public License v3.0 5 votes vote down vote up
public boolean filterEvent(Window window, int eventId) {
    switch (eventId) {
        case WindowEvent.WINDOW_OPENED:
        case WindowEvent.WINDOW_ACTIVATED:
            return true;
        default:
            return false;
    }
}
 
Example 19
Source File: NewerVersionFrameHandler.java    From IBC with GNU General Public License v3.0 5 votes vote down vote up
public boolean filterEvent(Window window, int eventId) {
    switch (eventId) {
        case WindowEvent.WINDOW_OPENED:
        case WindowEvent.WINDOW_ACTIVATED:
            return true;
        default:
            return false;
    }
}
 
Example 20
Source File: HelpAction.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public void eventDispatched (AWTEvent ev) {
    if (ev.getID() != WindowEvent.WINDOW_ACTIVATED)
        return;
    setCurrentActivatedWindow(((WindowEvent) ev).getWindow());
}