Multiscreen popups

Questions about YourKit Java Profiler
Post Reply
brendon9x
Posts: 1
Joined: Wed Sep 01, 2004 2:15 pm

Multiscreen popups

Post by brendon9x »

Hi,

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);
    }
This will just centre the popup in whichever Window has focus. For event driven popups, you may have to specify your main frame directly assuming there are no windows that have focus.

Regards,
Brendon McLean
Anton Katilin
Posts: 6172
Joined: Wed Aug 11, 2004 8:37 am

Post by Anton Katilin »

Hi Brendon,

Thank you very much for this suggestion. We'll try your approach and I hope we'll manage to support dual monitor configurations before the release of 3.1.
Post Reply