/** * Sizes the window's native host frame to match its preferred size. * * @param window */ public static void sizeHostToFit(Window window) { if (window == null) { throw new IllegalArgumentException(); } if (isFullScreen()) { throw new IllegalStateException(); } Dimensions size = window.getPreferredSize(); java.awt.Window hostWindow = window.getDisplay().getHostWindow(); java.awt.Insets frameInsets = hostWindow.getInsets(); hostWindow.setSize(size.width + (frameInsets.left + frameInsets.right), size.height + (frameInsets.top + frameInsets.bottom)); }
/** * Sizes the window's native host frame to match its preferred size. * * @param window */ public static void sizeHostToFit(Window window) { if (window == null) { throw new IllegalArgumentException(); } if (isFullScreen()) { throw new IllegalStateException(); } Dimensions size = window.getPreferredSize(); java.awt.Window hostWindow = window.getDisplay().getHostWindow(); java.awt.Insets frameInsets = hostWindow.getInsets(); hostWindow.setSize(size.width + (frameInsets.left + frameInsets.right), size.height + (frameInsets.top + frameInsets.bottom)); }
@Override public void layout() { Display display = (Display)getComponent(); // Set all components to their preferred sizes for (Component component : display) { Window window = (Window)component; if (window.isVisible()) { if (window.isMaximized()) { window.setSize(display.getSize()); } else { Dimensions preferredSize = window.getPreferredSize(); if (window.getWidth() != preferredSize.width || window.getHeight() != preferredSize.height) { window.setSize(preferredSize.width, preferredSize.height); } } } } } }
@Override public void layout() { Display display = (Display)getComponent(); // Set all components to their preferred sizes for (Component component : display) { Window window = (Window)component; if (window.isVisible()) { if (window.isMaximized()) { window.setSize(display.getSize()); } else { Dimensions preferredSize = window.getPreferredSize(); if (window.getWidth() != preferredSize.width || window.getHeight() != preferredSize.height) { window.setSize(preferredSize.width, preferredSize.height); } } } } } }