默认情况下,框架在screen左上角显示,坐标(0,0)改变其位置eg.
//得到screen的宽和高,java.awt.Toolkit
Dimension screenSize=Toolkit.getDefaultToolkit().getScreenSize();
int screenWidth=screenSize.width;
int screenHeight=screenSize.height;
//框架frame的左上角坐标
int x=(screenWidth-frame.getWidth())/2;
itn y=(screenHeight-frame.getHeight())/2;
时间: 2024-11-09 02:47:33