add method to get screen size
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Mon, 7 Apr 2008 09:01:28 +0000 (09:01 +0000)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Mon, 7 Apr 2008 09:01:28 +0000 (09:01 +0000)
git-svn-id: http://trooper/svn/projects/jSite/trunk@636 c3eda9e8-030b-0410-8277-bc7414b0a119

src/net/pterodactylus/util/swing/SwingUtils.java

index 103297b..e07a9fd 100644 (file)
@@ -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);
        }