I have created an applet that launches a JFrame with JPanel.
Everything works fine when only using a single monitor. I use pack()
to set the JFrame size.
The problem is that when dual monitors are used. If the second
monitor is of higher resolution than the first, then my JFrame will
create itself with the dimensions of the second monitor, eventhough it
is display on the first. Is there some way in a dual monitor system
to determine which monitor the app is displaying on, and then get that
monitor's resolution?
Thanks for you help.
California Paladin
Jonathan Fuerth - 17 Mar 2004 23:54 GMT
> I have created an applet that launches a JFrame with JPanel.
> Everything works fine when only using a single monitor. I use pack()
[quoted text clipped - 3 lines]
> monitor is of higher resolution than the first, then my JFrame will
> create itself with the dimensions of the second monitor, eventhough it
Why does your pack() operation depend on the screen size at all? Have
you set the preferred size of the content pane to the screen size?
> is display on the first. Is there some way in a dual monitor system
> to determine which monitor the app is displaying on, and then get that
> monitor's resolution?
I'm not sure. There might be a way to enumerate the physical displays
that make up a multi-screen virtual desktop in the new full-screen
exclusive API, but I don't know much about that except to say it's
definitely not supported on all platforms.
-Jonathan
Thomas Weidenfeller - 18 Mar 2004 08:56 GMT
> Is there some way in a dual monitor system
> to determine which monitor the app is displaying on, and then get that
> monitor's resolution?
Look up java.awt.GraphicsEnvironment, and work your way through the API
documentation.
/Thomas