Asg*_*har 3 java macos swing jframe
任何身体请帮助我,如何JFrame
在Mac 上居中.OS X?
我试过了:
this.setLocationRelativeto(null);
this.setLocationRelativeto(this);
this.setLocationRelativeto(getRootPane());
Run Code Online (Sandbox Code Playgroud)
..和
final Toolkit toolkit = Toolkit.getDefaultToolkit();
final Dimension screenSize = toolkit.getScreenSize();
final int x = (screenSize.width - this.getWidth()) / 2;
final int y = (screenSize.height - this.getHeight()) / 2;
this.setLocation(x, y);
Run Code Online (Sandbox Code Playgroud)
以上都没有工作,我的框架仍然在底部并隐藏在Mac底座后面.
打包框架后应设置位置(计算框架的大小).之后它应该是可见的(默认情况下它是隐藏的).
pack();
setLocationRelativeTo(null);
setVisible(true);
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
11150 次 |
最近记录: |