0

I work on a Java Swing application that allows displaying frames scattered on multiple screens.

The problem is, when in dual screen, a frame can be saved in secondary monitor 2 but when the application is loaded on only one monitor, the frame is off-screen and hence is not visible.

Does someone knows a way to identify and recover the frame to the main screen using Java Standard API?

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
bolbol
  • 77
  • 10
  • 1
    See [The Use of Multiple JFrames, Good/Bad Practice?](http://stackoverflow.com/a/9554657/418556) – Andrew Thompson May 13 '13 at 10:54
  • 1
    for better help sooner post an [SSCCE](http://sscce.org/), short, runnable, compilable, just about two empty JFrames, caused a.m. issue, additional details could be HW description about GPU, screens resolutions isn't important – mKorbel May 13 '13 at 10:54
  • 1
    Take a look [this](http://stackoverflow.com/questions/11714215/detect-current-screen-bounds/11714302#11714302) which demonstrates how to get the virtual bounds. Bascially you can check the bounds against those of the window and adjust the values as needed – MadProgrammer May 13 '13 at 10:56

1 Answers1

0

I think you could use:

public abstract GraphicsDevice[] getScreenDevices() throws HeadlessException 

Returns an array containing all the GraphicsDevice objects that represent screen devices

http://docs.oracle.com/javase/6/docs/api/java/awt/GraphicsEnvironment.html#getScreenDevices()

if this method give you list of two or more items then you have multimonitor environment.

Dmitry Zagorulkin
  • 8,370
  • 4
  • 37
  • 60