diff options
author | Jiri Vanek <[email protected]> | 2013-12-13 09:54:16 +0100 |
---|---|---|
committer | Jiri Vanek <[email protected]> | 2013-12-13 09:54:16 +0100 |
commit | 6256aac59275df0edd0feb4950272aa33573be9f (patch) | |
tree | adba1e61360cf9e18597a8736b8c50b5022605a0 /netx | |
parent | 26e9ef073e4ba4e625c8596113e9138ec85162e4 (diff) |
unittests warning cleanup: fixed typechecks, rawtypes, redundant casts...
ScreenFinder fixed to work partially also in headless mode.
After this clean up only "internal proprietary API and may be removed in a future release" warnings remain fro make check. Please keep itw in this way :)
Diffstat (limited to 'netx')
-rw-r--r-- | netx/net/sourceforge/jnlp/util/ScreenFinder.java | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/netx/net/sourceforge/jnlp/util/ScreenFinder.java b/netx/net/sourceforge/jnlp/util/ScreenFinder.java index b633ae2..5b5896c 100644 --- a/netx/net/sourceforge/jnlp/util/ScreenFinder.java +++ b/netx/net/sourceforge/jnlp/util/ScreenFinder.java @@ -39,12 +39,14 @@ package net.sourceforge.jnlp.util; import java.awt.GraphicsConfiguration; import java.awt.GraphicsDevice; import java.awt.GraphicsEnvironment; +import java.awt.HeadlessException; import java.awt.Insets; import java.awt.MouseInfo; import java.awt.Point; import java.awt.Rectangle; import java.awt.Toolkit; import java.awt.Window; +import net.sourceforge.jnlp.util.logging.OutputController; public class ScreenFinder { @@ -54,8 +56,13 @@ public class ScreenFinder { } public static Rectangle getCurrentScreenSizeWithoutBounds() { - Point p = MouseInfo.getPointerInfo().getLocation(); - return getScreenOnCoordsWithutBounds(p); + try { + Point p = MouseInfo.getPointerInfo().getLocation(); + return getScreenOnCoordsWithoutBounds(p); + } catch (HeadlessException ex) { + OutputController.getLogger().log(ex); + return new Rectangle(800, 600); + } } @@ -89,11 +96,16 @@ public class ScreenFinder { return result; } - public static Rectangle getScreenOnCoordsWithutBounds(Point p) { - GraphicsDevice device = getScreenOnCoords(p); - Rectangle screenSize = device.getDefaultConfiguration().getBounds(); - Insets insets = Toolkit.getDefaultToolkit().getScreenInsets(device.getDefaultConfiguration()); - return new Rectangle((int)screenSize.getX()+insets.left, (int)screenSize.getY()+insets.top, (int)screenSize.getWidth()-insets.left, (int)screenSize.getHeight()-insets.bottom); + public static Rectangle getScreenOnCoordsWithoutBounds(Point p) { + try { + GraphicsDevice device = getScreenOnCoords(p); + Rectangle screenSize = device.getDefaultConfiguration().getBounds(); + Insets insets = Toolkit.getDefaultToolkit().getScreenInsets(device.getDefaultConfiguration()); + return new Rectangle((int) screenSize.getX() + insets.left, (int) screenSize.getY() + insets.top, (int) screenSize.getWidth() - insets.left, (int) screenSize.getHeight() - insets.bottom); + } catch (HeadlessException ex) { + OutputController.getLogger().log(ex); + return new Rectangle(800, 600); + } } |