运行java时,窗体在屏幕中间显示的代码
import java.awt.*;
int width=0;
int height=0;
width=Toolkit.getDefaultToolkit().getScreenSize().width;
height=Toolkit.getDefaultToolkit().getScreenSize().height;
frame.setLocation((width - frameSize.width) / 2, (height - frameSize.height) / 2);
frame.setVisible(true);
int width=0;
int height=0;
width=Toolkit.getDefaultToolkit().getScreenSize().width;
height=Toolkit.getDefaultToolkit().getScreenSize().height;
frame.setLocation((width - frameSize.width) / 2, (height - frameSize.height) / 2);
frame.setVisible(true);