新手请教,怎样用Frame窗口实现运行时居中??
怎样用Frame窗口实现运行时居中
程序代码:import javax.swing.*;
/**
* Created by 日知己所无 on 2015/03/13.
*/
public class MyFrame extends JFrame {
public MyFrame() {
setAlwaysOnTop(true); // 置顶
setBounds(0, 0, 800, 600); // 窗体大小
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // 窗体右上方的关闭按钮有效
setLocationRelativeTo(null); // 置中
setResizable(false); // 窗体大小不可调整
setTitle("标题"); // 标题
setVisible(true); // 可视
}
public static void main(String[] args) {
MyFrame myFrame = new MyFrame();
}
}








