中国开发网: 论坛: 程序员情感CBD: 贴子 313947
空山新雨
... No such simple textbook question any more.
public class MainForm extends JFrame {

/**
* Constructor. Build the GUI interface.
*/
public MainForm(Client client) {
this.client = client;

buildMenu();
setJMenuBar(menuBar);

buildAccountTable();
buildActionTable();
buildPane();

getContentPane().setLayout(new BorderLayout());
getContentPane().add(statusBar, BorderLayout.SOUTH);
getContentPane().add(content, BorderLayout.CENTER);

setTitle("Action Robot");
setResizable(false);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
addWindowListener(new WindowAdapter() {
public void windowClosed(WindowEvent e) {
quit(e);
}
});
pack();

//Here answer your question.
Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
setLocation((int)((screen.getWidth() - getWidth()) / 2),
(int)((screen.getHeight() - getHeight()) / 2));
}

相关信息:


欢迎光临本社区,您还没有登录,不能发贴子。请在 这里登录