diff --git a/src/java/com/samskivert/swing/util/SwingUtil.java b/src/java/com/samskivert/swing/util/SwingUtil.java index 13c890f9..f529452e 100644 --- a/src/java/com/samskivert/swing/util/SwingUtil.java +++ b/src/java/com/samskivert/swing/util/SwingUtil.java @@ -77,10 +77,18 @@ public class SwingUtil */ public static void centerWindow (Window window) { - Toolkit tk = window.getToolkit(); - Dimension ss = tk.getScreenSize(); + Rectangle bounds; + try { + bounds = GraphicsEnvironment.getLocalGraphicsEnvironment(). + getDefaultScreenDevice().getDefaultConfiguration().getBounds(); + } catch (Throwable t) { + Toolkit tk = window.getToolkit(); + Dimension ss = tk.getScreenSize(); + bounds = new Rectangle(0, 0, ss.width, ss.height); + } + int width = window.getWidth(), height = window.getHeight(); - window.setBounds((ss.width-width)/2, (ss.height-height)/2, + window.setBounds(bounds.x + (bounds.width-width)/2, bounds.y + (bounds.height-height)/2, width, height); }