java.awt.Window#isVisible ( )源码实例Demo

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

源代码1 项目: openjdk-jdk8u-backup   文件: Test6541987.java
public static void main(String[] args) throws AWTException {
    robot = new Robot();
    // test escape after selection
    start();
    click(KeyEvent.VK_ESCAPE);
    toolkit.realSync();
    // test double escape after editing
    start();
    click(KeyEvent.VK_1);
    click(KeyEvent.VK_0);
    click(KeyEvent.VK_ESCAPE);
    click(KeyEvent.VK_ESCAPE);
    toolkit.realSync();
    // all windows should be closed
    for (Window window : Window.getWindows()) {
        if (window.isVisible()) {
            throw new Error("found visible window: " + window.getName());
        }
    }
}
 
源代码2 项目: hottub   文件: InputContext.java
private synchronized void notifyClientWindowChange(Window window) {
    if (inputMethod == null) {
        return;
    }

    // if the window is invisible or iconified, send null to the input method.
    if (!window.isVisible() ||
        ((window instanceof Frame) && ((Frame)window).getState() == Frame.ICONIFIED)) {
        clientWindowLocation = null;
        inputMethod.notifyClientWindowChange(null);
        return;
    }
    Rectangle location = window.getBounds();
    if (clientWindowLocation == null || !clientWindowLocation.equals(location)) {
        clientWindowLocation = location;
        inputMethod.notifyClientWindowChange(clientWindowLocation);
    }
}
 
源代码3 项目: ghidra   文件: AbstractDockingTest.java
public static Window waitForWindow(Class<?> windowClass) {

		if ((!Dialog.class.isAssignableFrom(windowClass)) &&
			(!Frame.class.isAssignableFrom(windowClass))) {
			throw new IllegalArgumentException(
				windowClass.getName() + " does not extend Dialog or Frame.");
		}

		int timeout = DEFAULT_WAIT_TIMEOUT;
		int totalTime = 0;
		while (totalTime <= timeout) {

			Set<Window> winList = getAllWindows();
			Iterator<Window> it = winList.iterator();
			while (it.hasNext()) {
				Window w = it.next();
				if (windowClass.isAssignableFrom(w.getClass()) && w.isVisible()) {
					return w;
				}
			}

			totalTime += sleep(DEFAULT_WAIT_DELAY);
		}

		throw new AssertionFailedError("Timed-out waiting for window of class: " + windowClass);
	}
 
源代码4 项目: ghidra   文件: AbstractDockingTest.java
/**
 * Waits for a window with the given name.
 *
 * @param name The name of the window for which to search
 * @return The window, if found, null otherwise
 */
public static Window waitForWindowByName(String name) {

	int time = 0;
	int timeout = DEFAULT_WAIT_TIMEOUT;
	while (time <= timeout) {
		Set<Window> allWindows = getAllWindows();
		for (Window window : allWindows) {
			String windowName = window.getName();
			if (name.equals(windowName) && window.isVisible()) {
				return window;
			}

			time += sleep(DEFAULT_WAIT_DELAY);
		}
	}

	throw new AssertionFailedError("Timed-out waiting for window with name '" + name + "'");
}
 
源代码5 项目: ghidra   文件: AbstractDockingTest.java
/**
 * Waits for the JDialog with the indicated title and that is parented to the indicated window
 * <P>
 * Note: Sometimes the task dialog might have the same title as the dialog you pop up and
 * you want to get yours instead of the one for the task monitor.
 *
 * @param window the parent window
 * @param title the title of the dialog
 * @param timeoutMS Maximum time to wait for the dialog
 * @return the dialog
 * @deprecated use {@link #waitForJDialog(String)} instead
 */
@Deprecated
public static JDialog waitForJDialog(Window window, String title, int timeoutMS) {

	int totalTime = 0;
	while (totalTime <= DEFAULT_WAIT_TIMEOUT) {

		Set<Window> winList = getWindows(window);
		Iterator<Window> iter = winList.iterator();
		while (iter.hasNext()) {
			Window w = iter.next();
			if ((w instanceof JDialog) && w.isVisible()) {
				String windowTitle = getTitleForWindow(w);
				if (title.equals(windowTitle)) {
					return (JDialog) w;
				}
			}
		}

		totalTime += sleep(DEFAULT_WAIT_DELAY);
	}
	throw new AssertionFailedError("Timed-out waiting for window with title '" + title + "'");
}
 
源代码6 项目: TencentKona-8   文件: InputContext.java
private synchronized void notifyClientWindowChange(Window window) {
    if (inputMethod == null) {
        return;
    }

    // if the window is invisible or iconified, send null to the input method.
    if (!window.isVisible() ||
        ((window instanceof Frame) && ((Frame)window).getState() == Frame.ICONIFIED)) {
        clientWindowLocation = null;
        inputMethod.notifyClientWindowChange(null);
        return;
    }
    Rectangle location = window.getBounds();
    if (clientWindowLocation == null || !clientWindowLocation.equals(location)) {
        clientWindowLocation = location;
        inputMethod.notifyClientWindowChange(clientWindowLocation);
    }
}
 
源代码7 项目: visualvm   文件: SysTray.java
private void hideWindow() {
    Window[] windows = mainWindow.getOwnedWindows();
    for (Window window : windows) {
        if (window.isVisible() && window instanceof Dialog)
            if (((Dialog)window).isModal()) {
                trayPopup.setEnabled(false);
                DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message(
                        Bundle.SysTray_ModalDialog(), NotifyDescriptor.WARNING_MESSAGE));
                trayPopup.setEnabled(true);
                return;
            }
    }

    mainWindow.setVisible(false);
    if (!Utilities.isWindows() && (mainWindow.getExtendedState() & Frame.ICONIFIED) != 0) {
        workaround = true;
    }
    if (showHideItem != null) showHideItem.setLabel(Bundle.SysTray_Show());
}
 
源代码8 项目: jdk8u-jdk   文件: Test6541987.java
public static void main(String[] args) throws AWTException {
    robot = new Robot();
    // test escape after selection
    start();
    click(KeyEvent.VK_ESCAPE);
    toolkit.realSync();
    // test double escape after editing
    start();
    click(KeyEvent.VK_1);
    click(KeyEvent.VK_0);
    click(KeyEvent.VK_ESCAPE);
    click(KeyEvent.VK_ESCAPE);
    toolkit.realSync();
    // all windows should be closed
    for (Window window : Window.getWindows()) {
        if (window.isVisible()) {
            throw new Error("found visible window: " + window.getName());
        }
    }
}
 
源代码9 项目: FancyBing   文件: Session.java
public void restoreLocation(Window window, Window owner, String name)
{
    int x = Integer.MIN_VALUE;
    int y = Integer.MIN_VALUE;
    Preferences prefs = getNode(name);
    if (prefs != null)
    {
        x = prefs.getInt("x", Integer.MIN_VALUE);
        y = prefs.getInt("y", Integer.MIN_VALUE);
    }
    if (x == Integer.MIN_VALUE || y == Integer.MIN_VALUE)
    {
        if (! window.isVisible())
            // use a platform-dependent default (setLocationByPlatform can
            // only be used, if window not already visible)
            window.setLocationByPlatform(true);
        return;
    }
    Point ownerLocation = owner.getLocation();
    setLocationChecked(window, x + ownerLocation.x,  y + ownerLocation.y);
}
 
源代码10 项目: openjdk-jdk9   文件: GUIBrowser.java
public RootNode() {
    super();
    Window[] wns = Frame.getFrames();
    wins = new WindowNode[wns.length];
    int count = 0;
    for (Window wn1 : wns) {
        if (propDialog.showAll || wn1.isVisible()) {
            count++;
        }
    }
    wins = new WindowNode[count];
    count = 0;
    for (Window wn : wns) {
        if (propDialog.showAll || wn.isVisible()) {
            wins[count] = new WindowNode(wn);
            count++;
        }
    }
}
 
源代码11 项目: jdk8u-dev-jdk   文件: Test6541987.java
public static void main(String[] args) throws AWTException {
    robot = new Robot();
    // test escape after selection
    start();
    click(KeyEvent.VK_ESCAPE);
    toolkit.realSync();
    // test double escape after editing
    start();
    click(KeyEvent.VK_1);
    click(KeyEvent.VK_0);
    click(KeyEvent.VK_ESCAPE);
    click(KeyEvent.VK_ESCAPE);
    toolkit.realSync();
    // all windows should be closed
    for (Window window : Window.getWindows()) {
        if (window.isVisible()) {
            throw new Error("found visible window: " + window.getName());
        }
    }
}
 
源代码12 项目: jdk8u-jdk   文件: Test6541987.java
public static void main(String[] args) throws AWTException {
    robot = new Robot();
    // test escape after selection
    start();
    click(KeyEvent.VK_ESCAPE);
    toolkit.realSync();
    // test double escape after editing
    start();
    click(KeyEvent.VK_1);
    click(KeyEvent.VK_0);
    click(KeyEvent.VK_ESCAPE);
    click(KeyEvent.VK_ESCAPE);
    toolkit.realSync();
    // all windows should be closed
    for (Window window : Window.getWindows()) {
        if (window.isVisible()) {
            throw new Error("found visible window: " + window.getName());
        }
    }
}
 
源代码13 项目: openjdk-jdk8u   文件: Test6541987.java
public static void main(String[] args) throws AWTException {
    robot = new Robot();
    // test escape after selection
    start();
    click(KeyEvent.VK_ESCAPE);
    toolkit.realSync();
    // test double escape after editing
    start();
    click(KeyEvent.VK_1);
    click(KeyEvent.VK_0);
    click(KeyEvent.VK_ESCAPE);
    click(KeyEvent.VK_ESCAPE);
    toolkit.realSync();
    // all windows should be closed
    for (Window window : Window.getWindows()) {
        if (window.isVisible()) {
            throw new Error("found visible window: " + window.getName());
        }
    }
}
 
源代码14 项目: netbeans   文件: RemoteAWTService.java
static Snapshot[] getGUISnapshots() {
    List snapshots = new ArrayList();   //System.err.println("gGUI: thread = "+Thread.currentThread());
    Window[] windows = Window.getWindows(); //System.err.println("gGUI: windows = "+windows.length);
    for (int wi = 0; wi < windows.length; wi++) {
        Window w = windows[wi]; //System.err.println("gGUI: w["+wi+"] = "+w+", is visible = "+w.isVisible());
        if (!w.isVisible()) {
            continue;
        }
        Dimension d = w.getSize();  //System.err.println("gGUI:  size = "+d);
        if (d.width == 0 || d.height == 0) {
            continue;
        }
        BufferedImage bi = new BufferedImage(d.width, d.height, BufferedImage.TYPE_INT_ARGB);
        Graphics2D g = bi.createGraphics();
        g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_DEFAULT);
        w.paint(g);
        Raster raster = bi.getData();
        Object data = raster.getDataElements(0, 0, d.width, d.height, null);
        int[] dataArr;  //System.err.println("gGUI: data = "+data);
        if (data instanceof int[]) {
            dataArr = (int[]) data;
        } else {
            continue;
        }
        String title = null;
        if (w instanceof Frame) {
            title = ((Frame) w).getTitle();
        } else if (w instanceof Dialog) {
            title = ((Dialog) w).getTitle();
        }   //System.err.println("gGUI: title = "+title);
        snapshots.add(new Snapshot(w, title, d.width, d.height, dataArr));
    }
    Snapshot[] snapshotArr = (Snapshot[]) snapshots.toArray(new Snapshot[] {});
    lastGUISnapshots = snapshotArr;
    return snapshotArr;
}
 
源代码15 项目: ghidra   文件: AbstractDockingTest.java
protected static Window getWindowByTitle(Window parentWindow, String title) {
	Set<Window> winList = getWindows(parentWindow);
	Iterator<Window> iter = winList.iterator();
	while (iter.hasNext()) {
		Window w = iter.next();
		if (!w.isVisible()) {
			continue;
		}
		String titleForWindow = getTitleForWindow(w);
		if (title.equals(titleForWindow)) {
			return w;
		}
	}
	return null;
}
 
源代码16 项目: netbeans   文件: WindowTable.java
/**
* @param vec is a ArrayList of windows
* @param grp is a ThreadGroup that belongs to the ArrayList
* @return true if all windows in the ArrayList vec are invisible
*/
private boolean hiddenWindows(ArrayList<Window> vec) {
    Iterator<Window> ee = vec.iterator();
    Window win;
    while (ee.hasNext()) {
        win = ee.next();
        if (win.isVisible()) return false;
    }
    // windows will be removed later
    return true;
}
 
源代码17 项目: ghidra   文件: AbstractDockingTest.java
/**
 * Gets the dialog component provider <b>that is inside the given window</b> or null if a
 * provider of the given class type is not in the window.
 *
 * @param window the window that contains the desired provider.
 * @param ghidraClass the class of the desired provider
 * @return the desired provider or null if the window does not contain a provider of the given type.
 */
protected static <T extends DialogComponentProvider> T getDialogComponentProvider(Window window,
		Class<T> ghidraClass) {

	if (!(window instanceof DockingDialog)) {
		return null;
	}

	if (!window.isVisible()) {
		return null;
	}

	if (!window.isShowing()) {
		return null;
	}

	DialogComponentProvider provider = ((DockingDialog) window).getDialogComponent();
	if (provider == null || !provider.isVisible()) {
		// provider can be null if the DockingDialog is disposed before we can get the provider
		return null;
	}

	if (!ghidraClass.isAssignableFrom(provider.getClass())) {
		return null;
	}

	return ghidraClass.cast(provider);
}
 
源代码18 项目: jeveassets   文件: TaskDialog.java
private Window getTopWindow(Window in) {
	for (Window window : in.getOwnedWindows()) {
		if (window.isVisible()) {
			return getTopWindow(window);
		}
	}
	return in;
}
 
源代码19 项目: netbeans   文件: JavaHelp.java
/**
 * If the help frame is opened from a modal dialog, it should be closed
 * automatically if that dialog closes. See bug 233543. Also the windows
 * should be rearranged so that both are visible. See bug #233542.
 */
private void bindFrameViewerToCurrentDialog() {
    int maxDepth = 0;
    Dialog topDialog = null;
    for (Window w : JDialog.getWindows()) {
        if (w instanceof Dialog && w.isVisible()) {
            Dialog d = (Dialog) w;
            if (isRelevantDialog(d)) {
                int depth = 0;
                for (Window o = d.getOwner(); o != null; o = o.getOwner()) {
                    depth++;
                    if (o == WindowManager.getDefault().getMainWindow()
                            && depth > maxDepth) {
                        maxDepth = depth;
                        topDialog = d;
                        break;
                    }
                }
            }
        }
    }
    if (topDialog != null) {
        rearrange(topDialog, frameViewer);
        final Dialog finalTopDialog = topDialog;
        topDialog.addWindowListener(new WindowAdapter() {

            @Override
            public void windowClosed(WindowEvent e) {
                if (frameViewer != null) {
                    frameViewer.setVisible(false);
                }
                finalTopDialog.removeWindowListener(this);
            }
        });
    }
}
 
源代码20 项目: FancyBing   文件: Session.java
public void saveVisible(Window window, String name)
{
    boolean isVisible = (window != null && window.isVisible());
    Preferences prefs = createNode(null);
    if (prefs == null)
        return;
    prefs.putBoolean("show-" + name, isVisible);
}