List<Window> visibleWindows = new ArrayList<Window>(); for(Window w: Window.getWindows()){ if(w.isShowing()){ visibleWindows.add(w); } }
if (window != null && window.isShowing()) { return window;
public static boolean isModalDialogShowing() { Window[] windows = Window.getWindows(); if( windows != null ) { // don't rely on current implementation, which at least returns [0]. for( Window w : windows ) { if( w.isShowing() && w instanceof Dialog && ((Dialog)w).isModal() ) return true; } } return false; }
public void componentResized(ComponentEvent e) { if(getWindowDecorationStyle() == JRootPane.NONE) return; // paint the non-opaque upper edges Window w = getWindow(); if(!w.isShowing()) return; w.repaint(0, 0, w.getWidth(), 5); } }
public boolean isShowing(){ Window window = searchWindow(); if( window == null ) return false; return window.isShowing(); } }
public void componentMoved(ComponentEvent e) { if(getWindowDecorationStyle() == JRootPane.NONE) return; // paint the non-opaque upper edges Window w = getWindow(); if(!w.isShowing()) return; w.repaint(0, 0, w.getWidth(), 5); }
/** * Marks the given window as "ready to use" and if not showing, as "hidden." * * @param w the given window. */ @RunsInCurrentThread void markExisting(@Nonnull Window w) { synchronized (lock) { open.put(w, true); if (!w.isShowing()) { hidden.put(w, true); } } }
private static @Nullable Window getAnyShowingWindow( final Window[] windows) { for (int i = 0, l = windows.length; i < l; i++) { Window window = windows[i]; if (window.isShowing()) return window; window = getAnyShowingWindow(window.getOwnedWindows()); if (window != null) return window; } return null; } }
private static @CheckForNull Window getAnyShowingWindow( final Window[] windows) { for (int i = 0, l = windows.length; i < l; i++) { Window window = windows[i]; if (window.isShowing()) return window; window = getAnyShowingWindow(window.getOwnedWindows()); if (window != null) return window; } return null; } }
private static @CheckForNull Window getAnyShowingWindow( final Window[] windows) { for (int i = 0, l = windows.length; i < l; i++) { Window window = windows[i]; if (window.isShowing()) return window; window = getAnyShowingWindow(window.getOwnedWindows()); if (window != null) return window; } return null; } }
private void scanExistingWindows(Window w) { // Make sure we catch subsequent show/hide events for this window attachWindowWatcherIfRequired(w); Window[] windows = w.getOwnedWindows(); for (int i=0;i < windows.length;i++) { scanExistingWindows(windows[i]); } openWindows.put(w, Boolean.TRUE); if (!w.isShowing()) { hiddenWindows.put(w, Boolean.TRUE); } noteContext(w); }
public void actionPerformed(ActionEvent e) { final Window window = getPopup(); if(window==null || window.isShowing()) { return; } window.pack(); window.setVisible(true); }
@Override public void hierarchyChanged(HierarchyEvent e) { if ((e.getChangeFlags() & HierarchyEvent.SHOWING_CHANGED) != 0) { if (e.getSource() instanceof Window) { Window secondaryWindow = (Window) e.getSource(); if (!secondaryWindow.isShowing()) { saveSession(secondaryWindow); } } } } }
public void hierarchyChanged(HierarchyEvent e) { if ((e.getChangeFlags() & HierarchyEvent.SHOWING_CHANGED) != 0) { if (e.getSource() instanceof Window) { Window secondaryWindow = (Window)e.getSource(); if (!secondaryWindow.isShowing()) { saveSession(secondaryWindow); } } } } }
private void learnWindow( Container c ) { if( c != null && c instanceof Window ) { win = (Window) c; win.addWindowListener( winL ); win.addComponentListener( cmpL ); if( EventManager.DEBUG_EVENTS ) { System.err.println( "DynamicAncestorAdapter added WindowListener : "+ win.getClass().getName() ); } if( !listening && win.isShowing() ) startListening(); } }
/** * Center a window on a parent window */ public static void centerWindow(Window parent, Window child) { Dimension parentSize = parent.getSize(); Dimension childSize = child.getSize(); Point parentLocation = new Point(0, 0); if (parent.isShowing()) { parentLocation = parent.getLocationOnScreen(); } int x = parentLocation.x + parentSize.width / 2 - childSize.width / 2; int y = parentLocation.y + parentSize.height / 2 - childSize.height / 2; child.setLocation(x, y); } }
@Override public void hierarchyChanged(final HierarchyEvent e) { if ((e.getChangeFlags() & HierarchyEvent.SHOWING_CHANGED) != HierarchyEvent.SHOWING_CHANGED) return; final Window window = getAncestorWindow(); assert null != window : "A showing panel must have a containing window!"; final boolean windowShown = window.isShowing(); if (windowShown != isShowing()) return; processPanelEvent(new PanelEvent(EnhancedPanel.this, windowShown ? PanelEvent.ANCESTOR_WINDOW_SHOWN : PanelEvent.ANCESTOR_WINDOW_HIDDEN)); } } // class EnhancedPanelHierarchyListener