Java Code Examples for java.awt.Window#getWindows()

The following examples show how to use java.awt.Window#getWindows() . 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: Test6541987.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
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());
        }
    }
}
 
Example 2
Source File: Test6541987.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
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());
        }
    }
}
 
Example 3
Source File: Test6541987.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
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());
        }
    }
}
 
Example 4
Source File: Test6541987.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
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());
        }
    }
}
 
Example 5
Source File: WindowTitle.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
public String getTitle() {
    String title = getTitleFromNP(window);
    Window[] windows = Window.getWindows();
    String original = title;
    int index = 1;
    for (Window w : windows) {
        if (w == window) {
            return title;
        }
        if (!w.isVisible()) {
            continue;
        }
        String wTitle = getTitleFromNP(w);
        if (original.equals(wTitle)) {
            title = original + "(" + index++ + ")";
        }
    }
    return title;
}
 
Example 6
Source File: EventQueueDevice.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
public Component getComponent() {
    if (component == null) {
        Window activeWindow = KeyboardFocusManager.getCurrentKeyboardFocusManager().getActiveWindow();
        if (activeWindow != null) {
            return activeWindow.getFocusOwner();
        }
        Window[] windows = Window.getWindows();
        if (windows.length > 0) {
            if (windows[0].getFocusOwner() != null) {
                return windows[0].getFocusOwner();
            }
            return windows[0];
        }
    }
    return component;
}
 
Example 7
Source File: Test6541987.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
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());
        }
    }
}
 
Example 8
Source File: Test6541987.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
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());
        }
    }
}
 
Example 9
Source File: Test6541987.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws AWTException {
    robot = new Robot();
    // test escape after selection
    start();
    click(KeyEvent.VK_ESCAPE);
    robot.waitForIdle();
    // test double escape after editing
    start();
    click(KeyEvent.VK_1);
    click(KeyEvent.VK_0);
    click(KeyEvent.VK_ESCAPE);
    click(KeyEvent.VK_ESCAPE);
    robot.waitForIdle();
    // all windows should be closed
    for (Window window : Window.getWindows()) {
        if (window.isVisible()) {
            throw new Error("found visible window: " + window.getName());
        }
    }
}
 
Example 10
Source File: MegaMekGUI.java    From megamek with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void preferenceChange(PreferenceChangeEvent e) {
    // Update to reflect new skin
    if (e.getName().equals(GUIPreferences.SKIN_FILE)) {
        showMainMenu();
        frame.repaint();
    } else if (e.getName().equals(GUIPreferences.UI_THEME)) {
        try {
            UIManager.setLookAndFeel((String)e.getNewValue());
            // We went all Oprah and gave everybody frames...
            // so now we have to let everybody who got a frame
            // under their chair know that we updated our look
            // and feel.
            for (Frame f : Frame.getFrames()) {
                SwingUtilities.updateComponentTreeUI(f);
            }
            // ...and also all of our windows and dialogs, etc.
            for (Window w : Window.getWindows()) {
                SwingUtilities.updateComponentTreeUI(w);
            }
        } catch (Exception ex) {
            DefaultMmLogger.getInstance().error(getClass(), "preferenceChange(GUIPreferences.UI_THEME)", ex);
        }
    }
}
 
Example 11
Source File: Test6541987.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
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());
        }
    }
}
 
Example 12
Source File: GUIUtils.java    From mzmine2 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Close all open MZmine windows, except the main (project) window
 */
public static void closeAllWindows() {
  for (Window window : Window.getWindows()) {
    if (window instanceof MainWindow)
      continue;
    window.dispose();
  }
}
 
Example 13
Source File: VectorImageDemo.java    From pumpernickel with MIT License 5 votes vote down vote up
@Override
public void eventDispatched(AWTEvent event) {
	KeyEvent e = (KeyEvent) event;
	if (e.getKeyCode() == KeyEvent.VK_F6
			&& e.getID() == KeyEvent.KEY_PRESSED) {
		PumpernickelShowcaseApp frame = null;
		for (Window w : Window.getWindows()) {
			if (w instanceof PumpernickelShowcaseApp)
				frame = (PumpernickelShowcaseApp) w;
		}
		VectorImage img = new VectorImage();
		img.getOperations().addListListener(
				new VectorImageInspector.StackTraceListener(), false);

		frame.paint(img.createGraphics());

		inspector.setVectorImage(img);
		cardLayout.show(cardPanel, "inspector");

		if (!VectorImageDemo.this.isShowing()) {
			JComponent content = QDialog.createContentPanel(
					"Would you like to switch to the VectorGraphics2D demo?",
					"Pressing F6 took a snapshot of the current window as a VectorGraphics2D.",
					null, // innerComponent,
					true);
			int option = QDialog.showDialog(frame,
					"Show VectorGraphics Demo",
					QDialog.QUESTION_MESSAGE, content, null, // leftControls,
					DialogFooter.OK_CANCEL_OPTION,
					DialogFooter.OK_OPTION, null, // dontShowKey,
					null, // alwaysApplyKey,
					DialogFooter.EscapeKeyBehavior.TRIGGERS_CANCEL);
			if (option == DialogFooter.OK_OPTION) {
				frame.showDemo(VectorImageDemo.this);
			}
		}
	}
}
 
Example 14
Source File: SettingsEditor.java    From gcs with Mozilla Public License 2.0 5 votes vote down vote up
public static SettingsEditor find(GURPSCharacter character) {
    for (Window window : Window.getWindows()) {
        if (window.isShowing() && window instanceof SettingsEditor) {
            SettingsEditor wnd = (SettingsEditor) window;
            if (wnd.mCharacter == character) {
                return wnd;
            }
        }
    }
    return null;
}
 
Example 15
Source File: RemoteAWTService.java    From netbeans with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example 16
Source File: FlatLaf.java    From FlatLaf with Apache License 2.0 4 votes vote down vote up
/**
 * Update UI of all application windows immediately.
 * Invoke after changing LaF.
 */
public static void updateUI() {
	for( Window w : Window.getWindows() )
		SwingUtilities.updateComponentTreeUI( w );
}
 
Example 17
Source File: Themes.java    From Pixelitor with GNU General Public License v3.0 4 votes vote down vote up
public static void updateAllUI() {
    Window[] windows = Window.getWindows();
    for (Window window : windows) {
        SwingUtilities.updateComponentTreeUI(window);
    }
}
 
Example 18
Source File: FiltersOptionsPanel.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public void storeTo(ProfilerIDESettings settings) {
    settings.setSourcesColoringEnabled(coloringChoice.isSelected());
    PackageColorer.setRegisteredColors(colors);
    for (Window w : Window.getWindows()) w.repaint();
}
 
Example 19
Source File: FiltersOptionsPanel.java    From visualvm with GNU General Public License v2.0 4 votes vote down vote up
public void storeTo(ProfilerIDESettings settings) {
    settings.setSourcesColoringEnabled(coloringChoice.isSelected());
    PackageColorer.setRegisteredColors(colors);
    for (Window w : Window.getWindows()) w.repaint();
}
 
Example 20
Source File: StartupDialog.java    From visualvm with GNU General Public License v2.0 4 votes vote down vote up
public static JDialog create(String caption, String message, int messageType) {
    // Bugfix #361, set the JDialog to appear in the Taskbar on Windows (ModalityType.APPLICATION_MODAL)
    Window[] windows = Window.getWindows();
    final JDialog d = windows == null || windows.length == 0 ?
            new JDialog(null, caption, JDialog.ModalityType.APPLICATION_MODAL) :
            new JDialog((Frame)null, caption, true);
    
    if (message != null) initDialog(d, message, messageType);
    
    // Bugfix #361, JDialog should use the VisualVM icon for better identification
    List<Image> icons = new ArrayList();
    icons.add(ImageUtilities.loadImage("org/netbeans/core/startup/frame.gif", true)); // NOI18N
    icons.add(ImageUtilities.loadImage("org/netbeans/core/startup/frame24.gif", true)); // NOI18N
    icons.add(ImageUtilities.loadImage("org/netbeans/core/startup/frame32.gif", true)); // NOI18N
    icons.add(ImageUtilities.loadImage("org/netbeans/core/startup/frame48.gif", true)); // NOI18N
    d.setIconImages(icons);
    
    d.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
    d.setResizable(false);
    d.setLocationRelativeTo(null);
    
    // Bugfix #361, ensure that the dialog will be the topmost visible window after opening
    d.addHierarchyListener(new HierarchyListener() {
        public void hierarchyChanged(HierarchyEvent e) {
            if ((e.getChangeFlags() & HierarchyEvent.SHOWING_CHANGED) != 0) {
                if (d.isShowing()) {
                    // For some reason the dialog created with defined JDialog.ModalityType
                    // isn't displayed on Windows when opened by the NetBeans launcher. This
                    // code seems to workaround it while not breaking anything elsewhere.
                    // Disabled to fix jigsaw, the problem is not reproducible using Java7u80@Win7
                    // ComponentPeer peer = d.getPeer();
                    // if (peer != null) peer.setVisible(true);

                    d.removeHierarchyListener(this);
                    d.setAlwaysOnTop(true);
                    d.toFront();
                    d.setAlwaysOnTop(false);
                }
            }
        }
    });
    
    return d;
}