www.pudn.com > DomView.zip > DomViewMenuBar.java


/******************************************************************** 
Domview 1.0 displays contents of an XML DOM object 
Copyright (C) 1999  The Bean Factory, LLC. 
 
This program is free software; you can redistribute it and/or 
modify it under the terms of the GNU General Public License 
as published by the Free Software Foundation; either version 2 
of the License, or (at your option) any later version. 
 
This program is distributed in the hope that it will be useful, 
but WITHOUT ANY WARRANTY; without even the implied warranty of 
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
GNU General Public License for more details. 
 
You should have received a copy of the GNU General Public License 
along with this program; if not, write to the Free Software 
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. 
 
Author: Sun Koh, The Bean Factory, LLC. 
*******************************************************************/ 
import java.awt.*;                  //AWT classes 
import java.awt.event.*;            //AWT event classes 
import java.util.*;                 //Vectors, etc 
import java.io.*;                   //Serializable, etc 
import java.net.*;                  //Network classes  
import javax.swing.*;               //Swing classes 
import javax.swing.event.*;         //Swing events 
import javax.swing.table.*;         //JTable models 
import javax.swing.tree.*;          //JTree models 
import javax.swing.border.*;        //JComponent Borders 
 
/******************************************************************** 
 DomViewMenuBar is a menu bar  
 
 
 @version      : 1.0 
 @author       : Sun Koh 
 
********************************************************************/ 
public class DomViewMenuBar 
extends JMenuBar 
implements java.io.Serializable{ 
// 
// Data Members 
// 
    protected DomView mainFrame; 
 
 
// 
// Methods 
// 
/** 
 Default Constructor  
 
 @param 
 */ 
public DomViewMenuBar(DomView d){ 
 
    mainFrame = d; 
 
    JMenu menu; 
    JMenuItem menuItem; 
 
    //create menu 
    menu = new JMenu("File"); 
    menuItem = new JMenuItem("Open"); 
    menuItem.addActionListener(new OpenAction()); 
    menu.add(menuItem); 
 
    menuItem = new JMenuItem("Close"); 
    menuItem.addActionListener(new CloseAction()); 
    menu.add(menuItem); 
     
    this.add(menu); 
 
    menu = new JMenu("Help"); 
    menuItem = new JMenuItem("JTree Display"); 
    menuItem.addActionListener(new DisplayAction()); 
    menu.add(menuItem); 
 
    menuItem = new JMenuItem("GPL"); 
    menuItem.addActionListener(new LicenseAction()); 
    menu.add(menuItem); 
 
    menuItem = new JMenuItem("About"); 
    menuItem.addActionListener(new AboutAction()); 
    menu.add(menuItem); 
 
    this.add(menu); 
 
} 
 
/** 
 Open action 
 */ 
public class OpenAction implements ActionListener{ 
    /** 
     * Invoked when an action occurs. 
     */ 
    public void actionPerformed(ActionEvent e) { 
 
        mainFrame.panel.showOpenFileDialog(); 
 
    } 
} 
 
public class CloseAction implements ActionListener{ 
    /** 
     * Invoked when an action occurs. 
     */ 
    public void actionPerformed(ActionEvent e) { 
        System.exit(0); 
    } 
} 
 
public class DisplayAction implements ActionListener{ 
    /** 
     * Invoked when an action occurs. 
     */ 
    public void actionPerformed(ActionEvent e) { 
        new HelpDisplayDialog(mainFrame); 
    } 
} 
 
public class AboutAction implements ActionListener{ 
    /** 
     * Invoked when an action occurs. 
     */ 
    public void actionPerformed(ActionEvent e) { 
        new HelpAboutDialog(mainFrame); 
    } 
} 
 
public class LicenseAction implements ActionListener{ 
    /** 
     * Invoked when an action occurs. 
     */ 
    public void actionPerformed(ActionEvent e) { 
        new HelpLicenseDialog(mainFrame); 
    } 
} 
 
 
 
}//end of DomViewMenuBar class