java设置窗体

public class 设置窗体 extends JFrame {

private JPanel contentPane;

/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
设置窗体 frame = new 设置窗体();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}

/**
* Create the frame.
*/
public 设置窗体() {
setTitle("u63A7u5236u7A97u4F53u52A0u8F7Du65F6u7684u4F4Du7F6E");
addWindowListener(new WindowAdapter() {
@Override
public void windowOpened(WindowEvent e) {
do_this_windowOpened(e);
}
});
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 450, 300);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
contentPane.setLayout(new BorderLayout(0, 0));
setContentPane(contentPane);
}

protected void do_this_windowOpened(WindowEvent e) {
setLocationRelativeTo(null);// 设置窗体居中
}
}

原文地址:https://www.cnblogs.com/fanzhengzheng/p/7503032.html