package divelog;
import javax.swing.awt.*;
import java.awt.*;
import java.awt.event.*;
public class Divelog {
public static void main(String[] args)
{
Divelog dl = new Divelog();
}
private JFrame dlframe;
private JTabbedPane tabbedPane;
public DiveLog(){
//create a frame object to add the appl gui components to
dlframe = new JFrame("A Java(TM) Technology Dive Log");
//closes from title bar and from menu
dlframe.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e)
{
system.exit(0);
}
});
//tabbed pane with panels for JComponents
tabbedPane = new JTabbedPane(SwingConstants.LEFT);
tabbedPane.setBackground(Color.blue);
tabbedPane.setForeground(Color.white);
//A method that adds individual tabs to the tabbedpane object.
populateTabbedPane();
//Calls the method that builds the menu
buildMenu();
dlframe.getContentPane().add(tabbedPane);
dlframe.pack();
dlframe.setSize(765, 690);
dlframe.setBackground(Color.white);
dlframe.setVisible(True);
} //end public DiveLog
private void populatetabbedPane() {
//create tabs with titles
tabbedPane.addTab("Welcome", null, new Welcome(), "Welcome to the Dive Log");
tabbedPane.addTab("Diver Data", null, new Diver(), "Click here to enter diver data");
tabbedPane.addTab("Log Dives", null, new Dives(), "Click here to enter dives");
tabbedPane.addTab("Statistics", null, new Statistics(), "Click here to calculate dive statistics");
tabbedPane.addTab("Favorite Website", null, new WebSite(), "Click here to see a web site");
tabbedPane.addTab("Resources", null, new Resources(), "Click here to see a list of resources");
} //end populatetabbedPane method
private void buildMenu() {
//instantiate JMenuBar, JMenu and JMenuItem
JMenuBar mb = new JMenuBar();
JMenu menu = new JMenu("File");
JMenu item = new JMenu("Exit");
//closes the application from the Exit menu item
item.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
System.exit(0);
}
});
//adds the item to the menu object
menu.add(item);
//adds the menu object with item to the menubar
mb.add(menu);
//sets the menubar in the frame
dlFrame.setJMenuBar(mb);
} //end buildMenu method
} //end public class DiveLog