[Schmitzm-commits] r2087 - trunk/schmitzm-core/src/main/java/de/schmitzm/swing

scm-commit at wald.intevation.org scm-commit at wald.intevation.org
Sat Sep 29 10:08:57 CEST 2012


Author: alfonx
Date: 2012-09-29 10:08:56 +0200 (Sat, 29 Sep 2012)
New Revision: 2087

Modified:
   trunk/schmitzm-core/src/main/java/de/schmitzm/swing/SwingUtil.java
Log:
New mehtod in SwingUtil to move a JFrame to a specific screen/monitor.

Modified: trunk/schmitzm-core/src/main/java/de/schmitzm/swing/SwingUtil.java
===================================================================
--- trunk/schmitzm-core/src/main/java/de/schmitzm/swing/SwingUtil.java	2012-09-28 17:18:28 UTC (rev 2086)
+++ trunk/schmitzm-core/src/main/java/de/schmitzm/swing/SwingUtil.java	2012-09-29 08:08:56 UTC (rev 2087)
@@ -40,6 +40,8 @@
 import java.awt.Font;
 import java.awt.Frame;
 import java.awt.Graphics2D;
+import java.awt.GraphicsDevice;
+import java.awt.GraphicsEnvironment;
 import java.awt.GridBagConstraints;
 import java.awt.Image;
 import java.awt.Point;
@@ -2410,4 +2412,29 @@
     
 
 
+    /**
+     * Move the given {@link JFrame} to a special Screen/monitor.  
+     * @param screenNr starting counting with 0
+     * @param frame
+     */
+    public static void showOnScreen( int screenNr, JFrame frame )
+    {
+        GraphicsEnvironment ge = GraphicsEnvironment
+            .getLocalGraphicsEnvironment();
+        GraphicsDevice[] gs = ge.getScreenDevices();
+        if( screenNr > -1 && screenNr < gs.length )
+        {
+            gs[screenNr].setFullScreenWindow( frame );
+        }
+        else if( gs.length > 0 )
+        {
+            gs[0].setFullScreenWindow( frame );
+        }
+        else
+        {
+            throw new RuntimeException( "No Screens Found" );
+        }
+    }
+
+
 }



More information about the Schmitzm-commits mailing list