I have been blessed with a dual screen display which is very useful for debugging and profiling. Youkit doesn't seem to be totally aware of the two screens and to be fair, it is quite tricky. The main problem being that Java and the OS can present the two monitors as either one big GraphicsDevice or two screen-sized GraphicsDevices depending on your setup. In our applications we've gotten around these problems with this code:
Code: Select all
public static void centreInFocusedWindow(Container containee) {
Window focusedWindow = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusedWindow();
Point containingFrameTopLeftHandCorner = focusedWindow.getLocation();
Dimension containingFrameSize = focusedWindow.getSize();
Dimension thisFrameSize = containee.getSize();
int x = (int) (containingFrameTopLeftHandCorner.getX() + (containingFrameSize.width / 2) - (thisFrameSize.width / 2));
int y = (int) (containingFrameTopLeftHandCorner.getY() + (containingFrameSize.height / 2) - (thisFrameSize.height / 2));
containee.setLocation(x, y);
}
Regards,
Brendon McLean