//http://developer.java.sun.com/developer/onlineTraining/new2java/divelog/part1/toc.jsp //package divelog; import javax.swing.*; import java.awt.*; import java.awt.event.*; public class DiveLog { //Opens DiveLog class private JTabbedPane tabbedPane; private JFrame dlframe; public DiveLog() { //Opens DiveLog constructor //Create a frame object to add the application //GUI components to. dlframe = new JFrame("A Java(TM) Technology Dive Log"); // Closes from title bar //and from menu dlframe.addWindowListener(new WindowAdapter() { // Opens addWindowListener method public void windowClosing(WindowEvent e) { // Opens windowClosing method System.exit(0); } // Closes windowClosing method }); // Closes addWindowListener method //Calls the method that builds the menu buildMenu(); Welcome xxx = new Welcome(); // that's what we want to display within the JFrame dlframe.getContentPane().add( xxx, BorderLayout.CENTER ); // add Welcome to the CENTER of JFrame dlframe.pack(); dlframe.setSize(765, 690); dlframe.setBackground(Color.white); dlframe.setVisible(true); } // Ends class constructor private void buildMenu() { // Opens buildMenu method definition JMenuBar mb = new JMenuBar(); JMenu menu = new JMenu("File"); JMenuItem item = new JMenuItem("Exit"); //Closes the application from the Exit //menu item. item.addActionListener(new ActionListener() { // Opens addActionListener method public void actionPerformed(ActionEvent e) { // Opens actionPerformed method System.exit(0); } // Closes actionPerformed method }); // Closes addActionListener method menu.add(item); mb.add(menu); dlframe.setJMenuBar(mb); }// Closes buildMenu method // main method and entry point for app public static void main(String[] args) { // Opens main method DiveLog dl = new DiveLog(); } // Closes main method } //Ends class DiveLog