• Post Reply Bookmark Topic Watch Topic
  • New Topic

choose runnig screen  RSS feed

 
nihel turki
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I'runnig jar file(from an other java code) using .batch file that contain this cmd : java -jar monJar.jar
My problem that i have 2 screens devices and i want to run this jar always in second one.
Is there is java code to choose that screen.
 
Rob Spoor
Sheriff
Posts: 21135
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Assuming it's a Swing application, you can use GraphicsDevice and its default configuration to find any screen, then use setLocation on the JFrame (or other root window) to move it to that screen.

If you're using JavaFX then you'll have to find the JavaFX equivalent.
 
nihel turki
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for your replay.
I used:
GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices()[1].setFullScreenWindow(my_window);
i it works
 
Rob Spoor
Sheriff
Posts: 21135
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome.

But I would check if the array returned by getScreenDevices() contains at least two elements before using [1] (if not use the only element). If you run your application on a machine with only one screen you'll now get an ArrayIndexOutOfBoundsException.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!