Java Reference
In-Depth Information
// find out where our database is
DatabaseLocationDialog dbLocation =
new DatabaseLocationDialog(this, connectionType);
try {
controller = new GuiController(dbLocation.getNetworkType(),
dbLocation.getLocation(),
dbLocation.getPort());
} catch (GUIControllerException gce) {
ApplicationRunner.handleException(
"Failed to connect to the database");
}
// Add the menu bar
JMenuBar menuBar = new JMenuBar ();
JMenu fileMenu = new JMenu ("File");
JMenuItem quitMenuItem = new JMenuItem ("Quit");
quitMenuItem.addActionListener(new QuitApplication ());
quitMenuItem.setMnemonic(KeyEvent.VK_Q);
fileMenu.add(quitMenuItem);
fileMenu.setMnemonic(KeyEvent.VK_F);
menuBar.add(fileMenu);
this.setJMenuBar(menuBar);
// A full data set is returned from an empty search
try {
tableData = controller.getDVDs();
setupTable();
} catch (GUIControllerException gce) {
ApplicationRunner.handleException(
"Failed to acquire an initial DVD list." +
"\nPlease check the DB connection.");
}
this.add(new DvdScreen());
this.pack();
this.setSize(650, 300);
// Center on screen
Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
int x = (int) ((d.getWidth() - this.getWidth())/ 2);
int y = (int) ((d.getHeight() - this.getHeight())/ 2);
this.setLocation(x, y);
this.setVisible(true);
Search WWH ::




Custom Search