空山新雨:
... No such simple textbook question any more.
[阅读: 396] 2006-04-18 02:57:06
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));
}