加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Java > 正文

Java Swing;如何制作,以便程序在屏幕的最右侧开始?

发布时间:2020-12-15 00:55:25 所属栏目:Java 来源:网络整理
导读:默认情况下,我的Swing程序从显示器的左上角开始.有没有办法让它在右侧弹出? 双显示器怎么样?我可以让它在右侧显示器上弹出吗? 谢谢. 卡罗 解决方法 假设您不想掩盖任务栏,则应使用getMaximumWindowBounds. Java API http://www.javabeginner.com/java-swi
默认情况下,我的Swing程序从显示器的左上角开始.有没有办法让它在右侧弹出?

双显示器怎么样?我可以让它在右侧显示器上弹出吗?

谢谢.

卡罗

解决方法

假设您不想掩盖任务栏,则应使用getMaximumWindowBounds.

Java API

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

Centering JFrame’s

By default,a Jframe is displayed in
the upper-left corner of the screen.
To display a frame at a specified
location,you can use the
setLocation(x,y) method in the JFrame
class. This method places the
upper-left corner of a frame at
location (x,y).

右上角的伪代码看起来像这样:

yourJFrame.setLocation(
  GraphicsEnvironment.getMaximumWindowBounds().getWidth() - 
  yourJFrame.getWidth(),0);

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读