List of utility methods to do Window
JFrame | getVisibleWindowByName(String name) Searches for a visible window with the supplied name. JFrame result = null; if (name != null) { Frame[] windows = JFrame.getFrames(); for (Frame window : windows) { if (window instanceof JFrame && window.isVisible() && name.equals(window.getName())) { result = (JFrame) window; break; return result; |
Window | getWindow(final Object source) get Window if (source instanceof JMenuItem) { final JMenuItem menuItem = (JMenuItem) source; MenuContainer menuContainer = menuItem.getParent(); while (menuContainer != null && !(menuContainer instanceof JPopupMenu)) { if (menuContainer instanceof MenuItem) { menuContainer = ((MenuItem) menuContainer).getParent(); } else { menuContainer = null; ... |
JFrame | getWindow(String title) get Window return windows.get(title);
|
Rectangle | getWindowNormalBounds(Window window) Gets Window bounds from the client property if (window instanceof JFrame) { Object res = ((JFrame) window).getRootPane().getClientProperty(WINDOW_STATE_NORMAL_BOUNDS); if (res instanceof Rectangle) { return (Rectangle) res; return null; |
String | getWindowTitle(Window window) get Window Title String title = null; if (window instanceof JDialog) { title = ((JDialog) window).getTitle(); } else if (window instanceof JFrame) { title = ((JFrame) window).getTitle(); return title; |
String | getWindowTitle(Window window) get Window Title if (window instanceof JFrame) { return ((JFrame) window).getTitle(); if (window instanceof JDialog) { return ((JDialog) window).getTitle(); return null; |
void | growIfNecessary(Window window) Grows the given Window if its preferred size exceeds its actual size. Dimension size = window.getSize(); Dimension pSize = getPreferredSize(window); window.setSize(Math.max(size.width, pSize.width), Math.max(size.height, pSize.height)); |
void | hideWaitPane(Window win, Timer timer) hide Wait Pane JPanel pane = new JPanel(); pane.setOpaque(false); if (win instanceof JFrame) { JFrame frame = (JFrame) win; frame.setGlassPane(pane); } else if (win instanceof JDialog) { JDialog dialog = (JDialog) win; dialog.setGlassPane(pane); ... |
void | installPrefsHandler(final Preferences prefs, final String name, Window window) Installs a window preferences handler. GraphicsConfiguration conf = window.getGraphicsConfiguration(); Rectangle screenBounds = conf.getBounds(); Insets screenInsets = window.getToolkit().getScreenInsets(conf); screenBounds.x += screenInsets.left; screenBounds.y += screenInsets.top; screenBounds.width -= screenInsets.left + screenInsets.right; screenBounds.height -= screenInsets.top + screenInsets.bottom; Dimension preferredSize = window.getPreferredSize(); ... |
boolean | isResizable(Window window) is Resizable JFrame frame = null; JDialog dialog = null; if (window instanceof JFrame) { frame = (JFrame) window; return (frame.isResizable() && (frame.getExtendedState() != JFrame.MAXIMIZED_BOTH)); } else if (window instanceof Dialog) { dialog = (JDialog) window; return (dialog != null && dialog.isResizable()); ... |