From: David ‘Bombe’ Roden Date: Mon, 7 Apr 2008 09:01:28 +0000 (+0000) Subject: add method to get screen size X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=8740c8502c3b9db772d07ab855de10555b5effd3;p=jSite2.git add method to get screen size git-svn-id: http://trooper/svn/projects/jSite/trunk@636 c3eda9e8-030b-0410-8277-bc7414b0a119 --- diff --git a/src/net/pterodactylus/util/swing/SwingUtils.java b/src/net/pterodactylus/util/swing/SwingUtils.java index 103297b..e07a9fd 100644 --- a/src/net/pterodactylus/util/swing/SwingUtils.java +++ b/src/net/pterodactylus/util/swing/SwingUtils.java @@ -33,6 +33,18 @@ import java.awt.Window; */ 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. * @@ -40,7 +52,6 @@ public class SwingUtils { * 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); }