Topic: 请问如何使JFrame JDialog居中显示?

  Print this page

1.请问如何使JFrame JDialog居中显示? Copy to clipboard
Posted by: HurricaneJKJ
Posted on: 2004-08-25 11:32

请问如何使JFrame JDialog居中显示?

2.Re:请问如何使JFrame JDialog居中显示? [Re: HurricaneJKJ] Copy to clipboard
Posted by: sunwave
Posted on: 2004-09-01 19:04

TechInfoDialog dlg = new TechInfoDialog(this, "职称信息维护", true);
Toolkit kit = Toolkit.getDefaultToolkit();
Dimension screenSize = kit.getScreenSize();
int width = (int) screenSize.getWidth();
int height = (int) screenSize.getHeight();
dlg.setSize(600, 500);
int w = dlg.getWidth();
int h = dlg.getHeight();
dlg.setLocation( (width - w) / 2, (height - h) / 2);
dlg.setVisible(true);

3.Re:请问如何使JFrame JDialog居中显示? [Re: HurricaneJKJ] Copy to clipboard
Posted by: tzutolin
Posted on: 2004-09-03 00:00

Try this:
setLocationRelativeTo(null)

Best regards,
tzutolin


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923