/*
 * Gary Cornell and Cay S. Horstmann, Core Java (Book/CD-ROM)
 * Published By SunSoft Press/Prentice-Hall
 * Copyright (C) 1996 Sun Microsystems Inc.
 * All Rights Reserved. ISBN 0-13-565755-5
 *
 * Permission to use, copy, modify, and distribute this 
 * software and its documentation for NON-COMMERCIAL purposes
 * and without fee is hereby granted provided that this 
 * copyright notice appears in all copies. 
 * 
 * THE AUTHORS AND PUBLISHER MAKE NO REPRESENTATIONS OR 
 * WARRANTIES ABOUT THE SUITABILITY OF THE SOFTWARE, EITHER 
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 
 * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 
 * PARTICULAR PURPOSE, OR NON-INFRINGEMENT. THE AUTHORS
 * AND PUBLISHER SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED 
 * BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING 
 * THIS SOFTWARE OR ITS DERIVATIVES.
 */
 
/**
 * @version 1.00 07 Feb 1996 
 * @author Cay Horstmann
 */

import java.awt.*;
import java.applet.*;

public class MenuTest extends Applet
{  
   Frame myframe;
   
   public void init()
   { // setTitle("MenuTest");
      add(new Button("Men"));
      myframe = new Frame();
      myframe.resize(300,200);
      
      MenuBar mbar = new MenuBar();
      
      Menu m = new Menu("Datei");
      m.add(new MenuItem("Neu"));
      m.add(new MenuItem("™ffnen"));
      m.addSeparator();
      m.add(new MenuItem("Sichern"));
      m.add(new MenuItem("Sichern als"));
      m.addSeparator();
      m.add(new MenuItem("Drucken"));
      m.addSeparator();
      m.add(new MenuItem("Ende"));            
      mbar.add(m);
        
      m = new Menu("Editieren");
      m.add(new MenuItem("Undo"));
      m.add(new MenuItem("Redo"));
      m.addSeparator();
      m.add(new MenuItem("Ausschneiden"));
      m.add(new MenuItem("Kopieren"));
      m.add(new MenuItem("L÷schen"));
      m.add(new MenuItem("Einfgen"));
      m.addSeparator();
        
      Menu f = new Menu("Optionen");
      f.add(new CheckboxMenuItem("Auto Einfgen"));
      f.add(new CheckboxMenuItem("Auto Ident."));
      m.add(f);
        
        
      mbar.add(m);
      
                
      m = new Menu("Hilfe");
      m.add(new MenuItem("Index"));
      m.add(new MenuItem("šber"));
      mbar.add(m);

      myframe.setMenuBar(mbar);
   }      


   public boolean action(Event evt, Object arg)
   {  if (evt.target instanceof MenuItem)
      {  if(arg.equals("Ende"))
            System.exit(0);
      }
      else if(arg.equals("Men"))
           {
            if (myframe.isShowing()) myframe.hide();
            else myframe.show();
           }
      else return false;
      return true;
   }

   public boolean handleEvent(Event evt)
   {  if (evt.id == Event.WINDOW_DESTROY 
         && evt.target == this)
         System.exit(0);
      return super.handleEvent(evt);
   }
   

}



                     
