From 8740c8502c3b9db772d07ab855de10555b5effd3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Mon, 7 Apr 2008 09:01:28 +0000 Subject: [PATCH] add method to get screen size git-svn-id: http://trooper/svn/projects/jSite/trunk@636 c3eda9e8-030b-0410-8277-bc7414b0a119 --- src/net/pterodactylus/util/swing/SwingUtils.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) 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); } -- 2.7.4