*/
public class SwingUtils {
+ /** The screen size. */
+ private static Dimension screenDimension = Toolkit.getDefaultToolkit().getScreenSize();
+
+ /**
+ * Returns the size of the screen.
+ *
+ * @return The size of the screen
+ */
+ public Dimension getScreenSize() {
+ return new Dimension(screenDimension);
+ }
+
/**
* Centers the given window on the screen.
*
* The window to center
*/
public static void center(Window window) {
- Dimension screenDimension = Toolkit.getDefaultToolkit().getScreenSize();
Dimension frameDimension = window.getSize();
window.setLocation((screenDimension.width - frameDimension.width) >> 1, (screenDimension.height - frameDimension.height) >> 1);
}