Java Swing; How do I make it so that the program starts on the far right side of the screen?

By default, my swing program starts at the top left corner of the display Is there any way to make it pop up on the right?

How about dual monitors? Can I have it pop up on the right monitor?

thank you.

Carol

Solution

Assuming you don't want to mask the taskbar, you should use getmaximumwindowbounds

Java API

http://www.javabeginner.com/java-swing/java-jframe-class-example

The pseudo code in the upper right corner looks like this:

yourJFrame.setLocation(
  GraphicsEnvironment.getMaximumWindowBounds().getWidth() - 
  yourJFrame.getWidth(),0);
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>