Java Reference
In-Depth Information
Listing 8-31. The ServerWindow Constructor
public ServerWindow() {
super("Denny's DVDs Server Application");
this.setDefaultCloseOperation(this.EXIT_ON_CLOSE);
this.setResizable(false);
Runtime.getRuntime().addShutdownHook(new CleanExit());
// Add the menu bar
JMenuBar menuBar = new JMenuBar ();
JMenu fileMenu = new JMenu ("File");
JMenuItem quitMenuItem = new JMenuItem ("Quit");
quitMenuItem.addActionListener(new ActionListener() {
public void actionPerformed (ActionEvent ae) {
System.exit(0);
}
});
quitMenuItem.setMnemonic(KeyEvent.VK_Q);
fileMenu.add(quitMenuItem);
fileMenu.setMnemonic(KeyEvent.VK_F);
menuBar.add(fileMenu);
this.setJMenuBar(menuBar);
configOptionsPanel.getObservable().addObserver(this);
this.add(configOptionsPanel, BorderLayout.NORTH);
this.add(commandOptionsPanel(), BorderLayout.CENTER);
status.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
JPanel statusPanel = new JPanel(new BorderLayout());
statusPanel.add(status, BorderLayout.CENTER);
this.add(statusPanel, BorderLayout.SOUTH);
// load saved configuration
SavedConfiguration config = SavedConfiguration.getSavedConfiguration();
// there may not be a default database location, so we had better
// validate before using the returned value.
String databaseLocation =
config.getParameter(SavedConfiguration.DATABASE_LOCATION);
configOptionsPanel.setLocationFieldText(
(databaseLocation == null) ? "" : databaseLocation);
// there is always at least a default port number, so we don't have to
// validate this.
configOptionsPanel.setPortNumberText(
config.getParameter(SavedConfiguration.SERVER_PORT));
Search WWH ::




Custom Search