Creating Menus

There's an alternative add() method in java.awt.Menu that accepts a string as an argument. This string is just the label of the menu item. This method still creates new MenuItem objects. It just does it behind your back. Here's how it would be used

    Menu editMenu = new Menu("Edit");
    editMenu.add("Undo");
    editMenu.addSeparator();
    editMenu.add("Cut");
    editMenu.add("Copy");
    editMenu.add("Paste");
    editMenu.add("Clear");
    editMenu.addSeparator();
    editMenu.add("Select All");

Previous | Next | Top
Last Modified June 30, 1999
Copyright 1997, 1999 Elliotte Rusty Harold
elharo@metalab.unc.edu