List of usage examples for java.awt Component setSize
public void setSize(Dimension d)
From source file:pcgen.gui2.tools.Utility.java
/** * Update the size of the dialog to ensure it will fit on the screen. * * @param dialog The dialog to be resized. */// w ww. j a v a 2 s. c o m public static void resizeComponentToScreen(Component dialog) { // Get the maximum window size to account for taskbars etc Rectangle screenBounds = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds(); final Dimension dialogSize = dialog.getSize(); if (dialogSize.height > screenBounds.height) { dialogSize.height = screenBounds.height; } if (dialogSize.width > screenBounds.width) { dialogSize.width = screenBounds.width; } dialog.setSize(dialogSize); }