/* * Copyright 2003 Sun Microsystems, Inc. ALL RIGHTS RESERVED * Use of this software is authorized pursuant to the terms * of the license found at * http://developer.java.sun.com/berkeley_license.html. */ package divelog; import javax.swing.*; import java.awt.*; import java.awt.event.*; public class DiveLog extends JFrame { private JTabbedPane tabbedPane; public DiveLog() { //Create a frame object to add the application //GUI components to. super("A Java(TM) Technology Dive Log"); // Closes from title bar //and from menu 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(); getContentPane().add(tabbedPane); } 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 Web Site", null, new WebSite(), "Click here to see a web site"); tabbedPane.addTab("Resources", null, new Resources(), "Click here to see a list of resources"); } //Ends populateTabbedPane method private void buildMenu() { 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() { public void actionPerformed(ActionEvent e) { System.exit(0); } });// Ends buildMenu method menu.add(item); mb.add(menu); setJMenuBar(mb); } public static void main(String[] args) { DiveLog dl = new DiveLog(); dl.pack(); dl.setSize(765, 690); dl.setBackground(Color.white); dl.setVisible(true); } } //Ends class