@Override public void windowClosed(final WindowEvent e) { Window[] windows = Window.getWindows(); if (windows == null || windows.length == 0) { System.exit(0); } } }
@Override public void windowClosed(final WindowEvent e) { Window[] windows = Window.getWindows(); if (windows == null || windows.length == 0) { System.exit(0); } } }
java.awt.Window win[] = java.awt.Window.getWindows(); for(int i=0;i<win.length;i++){ if (win[i].getName().equals("YourWindowName")) isOpen = true; break; }
public Window getActiveWindow() { for (Window frame : Window.getWindows()) { if (frame.isActive()) { return frame; } } return this; }
import java.awt.Window; import javax.swing.JDialog; public class Test { public static void main(String[] args) { JDialog d = new JDialog((Window)null,"Demo Dialog"); for (Window w : JDialog.getWindows()) { if ( w instanceof JDialog) { System.out.println(((JDialog)w).getTitle()); } } } }
public boolean isAppActive() { for (Window frame : Window.getWindows()) { if (frame.isActive()) { return true; } } return false; }
@Override public void run() { for (Window window : Window.getWindows()) { SwingUtilities.updateComponentTreeUI(window); } } });
public void run() { for (Window window : Window.getWindows()) { SwingUtilities.updateComponentTreeUI(window); } } });
@Deprecated public boolean isFrame() { Window[] ws = Window.getWindows(); for (Window w : ws) { if (w.isActive()) { return w instanceof JFrame; } } throw new RuntimeException(); // return displayStack.peek().getWindow() instanceof JFrame; }
@Deprecated public boolean isDialog() { Window[] ws = Window.getWindows(); for (Window w : ws) { if (w.isActive()) { return w instanceof JDialog; } } throw new RuntimeException(); // return displayStack.peek().getWindow() instanceof JDialog; }
@Deprecated public Window peek() { Window[] ws = Window.getWindows(); for (Window w : ws) { if (w.isActive()) { return w; } } throw new RuntimeException(); // return displayStack.peek().getWindow(); }
/** * @return true if any app window has focus */ public static boolean appHasFocus() { return Utils.anyMatch(Window.getWindows(), Window::isActive); }
/** * Updates the componentTreeUI of all top-level windows of the * current application. * */ public static void updateAllComponentTreeUIs() { // for (Frame frame : Frame.getFrames()) { // updateAllComponentTreeUIs(frame); // } // JW: updated to new 1.6 api - returns all windows, owned and ownerless for (Window window: Window.getWindows()) { SwingUtilities.updateComponentTreeUI(window); } }
/** * Return all of the visible JWindows, JDialogs, and JFrames per * Window.getWindows() on Java SE 6 */ private List<Window> getVisibleSecondaryWindows() { List<Window> rv = new ArrayList<Window>(); for (Window window : Window.getWindows()) { if (isVisibleWindow(window)) { rv.add(window); } } return rv; }
/** * Updates the componentTreeUI of all top-level windows of the * current application. * */ public static void updateAllComponentTreeUIs() { // for (Frame frame : Frame.getFrames()) { // updateAllComponentTreeUIs(frame); // } // JW: updated to new 1.6 api - returns all windows, owned and ownerless for (Window window: Window.getWindows()) { SwingUtilities.updateComponentTreeUI(window); } }
/** * Updates the componentTreeUI of all top-level windows of the * current application. * */ public static void updateAllComponentTreeUIs() { // for (Frame frame : Frame.getFrames()) { // updateAllComponentTreeUIs(frame); // } // JW: updated to new 1.6 api - returns all windows, owned and ownerless for (Window window: Window.getWindows()) { SwingUtilities.updateComponentTreeUI(window); } }
public static void updateLookAndFeel() { for (Window w : Window.getWindows()) { if (w.isDisplayable()) { SwingUtilities.updateComponentTreeUI(w); } } } }
@NotNull public static Window getActiveWindow() { Window[] windows = Window.getWindows(); for (Window each : windows) { if (each.isVisible() && each.isActive()) return each; } return JOptionPane.getRootFrame(); }
private void replaceComponentText() { for (Window window : Window.getWindows()) { final Point mousePosition = window.getMousePosition(true); if (mousePosition != null) { final Component componentUnderMouse = SwingUtilities.getDeepestComponentAt(window, mousePosition.x, mousePosition.y); replaceComponentTexts(componentUnderMouse); } } }
private void repaintWindows() { for (Window window : Window.getWindows()) { window.repaint(); } List<PopupInfo> popups = PopupPanelManager.defaultManager() .getShownPath(); for (PopupPanelManager.PopupInfo popup : popups) { JPopupPanel popupPanel = popup.getPopupPanel(); popupPanel.paintImmediately(new Rectangle(0, 0, popupPanel .getWidth(), popupPanel.getHeight())); } }