Example usage for java.awt Window isActive

List of usage examples for java.awt Window isActive

Introduction

In this page you can find the example usage for java.awt Window isActive.

Prototype

public boolean isActive() 

Source Link

Document

Returns whether this Window is active.

Usage

From source file:Main.java

/**
 * Returns active application window./*from ww w.  ja  va 2s.  co m*/
 *
 * @return active application window
 */
public static Window getActiveWindow() {
    final Window[] windows = Window.getWindows();
    Window window = null;
    for (final Window w : windows) {
        if (w.isShowing() && w.isActive() && w.isFocused()) {
            window = w;
            break;
        }
    }
    return window;
}

From source file:com.github.srec.rec.DefaultScreenShot.java

private Window findActiveWindow() {
    Window[] ws = Window.getOwnerlessWindows();
    if (ws.length == 0) {
        return null;
    }/*from  w  w w.j  av a 2s  .  co  m*/
    for (Window w : ws) {
        if (w.isActive()) {
            return w;
        }
    }
    return null;
}

From source file:org.eclipse.jubula.rc.swing.components.AUTSwingHierarchy.java

/**
 * Searchs for the component in the AUT with the given
 * <code>componentIdentifier</code>.
 * @param componentIdentifier the identifier created in object mapping mode
 * @throws IllegalArgumentException if the given identifer is null or <br>the hierarchy is not valid: empty or containing null elements
 * @throws InvalidDataException if the hierarchy in the componentIdentifier does not consist of strings
 * @throws ComponentNotManagedException if no component could be found for the identifier
 * @return the instance of the component of the AUT 
 *///from www  .ja  v a  2 s  .co  m
public Component findComponent(IComponentIdentifier componentIdentifier)
        throws IllegalArgumentException, ComponentNotManagedException, InvalidDataException {
    Component comp = (Component) findBP.findComponent(componentIdentifier, ComponentHandler.getAutHierarchy());

    if (comp != null && comp.isShowing()) {
        Window window = SwingUtilities.getWindowAncestor(comp);
        if (window != null && window.isShowing() && !window.isActive()) {
            window.toFront();
        }
        return comp;
    }
    throw new ComponentNotManagedException("unmanaged component with identifier: '" //$NON-NLS-1$
            + componentIdentifier.toString() + "'.", //$NON-NLS-1$ 
            MessageIDs.E_COMPONENT_NOT_MANAGED);
}