public boolean isActive() { if( w != null ) { return w.isActive(); } else { return false; } }
// Workaround for issue // (http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6770457) PopupFactory.setSharedInstance(new PopupFactory() { @Override public Popup getPopup(Component owner, Component contents, int x, int y) { Window win = SwingUtilities.getWindowAncestor(owner); if (win.isActive()) { return super.getPopup(owner, contents, x, y); } return super.getPopup(JOptionPane.getRootFrame(), contents, x, y); } }); // end fix
public Window getActiveWindow() { for (Window frame : Window.getWindows()) { if (frame.isActive()) { return frame; } } return this; }
public boolean isAppActive() { for (Window frame : Window.getWindows()) { if (frame.isActive()) { return true; } } return false; }
for (Window frame : Window.getWindows()) { if (frame.isActive()) { frame.setVisible(false); } }
@Deprecated public Window peek() { Window[] ws = Window.getWindows(); for (Window w : ws) { if (w.isActive()) { return w; } } throw new RuntimeException(); // return displayStack.peek().getWindow(); }
public boolean isSelected() { Window window = getWindow(); return (window == null) ? true : window.isActive(); }
@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; }
/** * Tells whether the focus of this component is currently lost, but * will be retrieved as soon as the underlying frame gets activated. * @return <code>true</code> if the focus is only temporarily lost */ public boolean isFocusTemporarilyLost(){ Window window = SwingUtilities.getWindowAncestor( getComponent() ); boolean focusTemporarilyLost = false; if( window != null ){ focusTemporarilyLost = !window.isActive(); } return focusTemporarilyLost; }
/** * Tells whether the focus of this component is currently lost, but * will be retrieved as soon as the underlying frame gets activated. * @return <code>true</code> if the focus is only temporarily lost */ public boolean isFocusTemporarilyLost(){ Window window = SwingUtilities.getWindowAncestor( getComponent() ); boolean focusTemporarilyLost = false; if( window != null ){ focusTemporarilyLost = !window.isActive(); } return focusTemporarilyLost; }
public void add( Window window ){ if( monitored.add( window ) ){ window.addWindowFocusListener( listener ); if( window.isActive() ){ current = window; fireWindowChanged( window ); history.add( current ); } else{ history.add( 0, window ); } } }
public void add( Window window ){ if( monitored.add( window ) ){ window.addWindowFocusListener( listener ); if( window.isActive() ){ current = window; fireWindowChanged( window ); history.add( current ); } else{ history.add( 0, window ); } } }
/** * Returns <code>true</code> if this MainFrame is active, or is an ancestor of a Window that is currently active. * * @return <code>true</code> if this MainFrame is active, or is an ancestor of a Window that is currently active */ public boolean isAncestorOfActiveWindow() { if(isActive()) return true; Window ownedWindows[] = getOwnedWindows(); int nbWindows = ownedWindows.length; for(int i=0; i<nbWindows; i++) if(ownedWindows[i].isActive()) return true; return false; }
Window getSelectedWindow(Window[] windows) { Window result = null; for (int i = 0; i < windows.length; i++) { Window window = windows[i]; if (window.isActive()) { result = window; } else { Window[] ownedWindows = window.getOwnedWindows(); if (ownedWindows != null) { result = getSelectedWindow(ownedWindows); } } } return result; }
@NotNull public static Window getActiveWindow() { Window[] windows = Window.getWindows(); for (Window each : windows) { if (each.isVisible() && each.isActive()) return each; } return JOptionPane.getRootFrame(); }
public static boolean isPaintRootPaneActivated(JRootPane rp) { if (isRootPaneAutoDeactivate(rp)) { Component c = rp.getParent(); if (c instanceof JInternalFrame) { return ((JInternalFrame)c).isSelected(); } else if (c instanceof Window) { return ((Window)c).isActive(); } else { return false; } } else { return true; } }
@Override public boolean dispatchKeyEvent(final KeyEvent e) { if (!window.isActive()) return false; if (e.getID() == KeyEvent.KEY_TYPED) { final int code = KeyCodeConverter.getKeyCode(e); SwingUtilities.invokeLater(() -> { final KeyCommand command = getInputCommandFactory().getKeyCommand(code); getCommandExecutor().execute(command); }); } return false; }
@Override public void addNotify() { super.addNotify(); uninstallListeners(); window = SwingUtilities.getWindowAncestor(this); if (window != null) { if (window instanceof Frame) { setState(((Frame) window).getExtendedState()); } else { setState(0); } setActive(window.isActive()); installListeners(); } }