Class Menu
All Packages Class Hierarchy This Package Previous Next Index
Class Menu
public class netscape.application.Menu
extends java.lang.Object
implements netscape.util.Codable
{
/* Constructors
*/
public Menu();
public Menu(boolean);
/* Methods
*/
public MenuItem addItem(String, String, Target);
public MenuItem addItem(String, String, Target, boolean);
public MenuItem addItem(String, char, String, Target);
public MenuItem addItem(String, char, String, Target, boolean);
public MenuItem addItemAt(String, char, String, Target, boolean, int);
public void addItemAt(MenuItem, int);
public MenuItem addItemWithSubmenu(String);
public MenuItem addSeparator();
public Color backgroundColor();
public Border border();
protected Menu createMenuAsSubmenu();
public void decode(Decoder);
public void describeClassInfo(ClassInfo);
public void encode(Encoder);
public void finishDecoding();
public boolean handleCommandKeyEvent(KeyEvent);
public int indexOfItem(MenuItem);
public boolean isTransparent();
public MenuItem itemAt(int);
public int itemCount();
public void performCommand(String, Object);
public MenuItem prototypeItem();
public void removeItem(MenuItem);
public void removeItemAt(int);
public void replaceItem(MenuItem, MenuItem);
public void replaceItemAt(int, MenuItem);
public void setBackgroundColor(Color);
public void setBorder(Border);
public void setPrototypeItem(MenuItem);
public void setTransparent(boolean);
}
Object subclass managing a collection of MenuItems.
There are two Menu types: top-level main
Menus and submenus (a menu invoked by a MenuItem). Both of these types
of Menus can be used for AWT-based native Menus as well as IFC View-based
pure java Menus. Top-level menus have an
associated java.awt.MenuBar, while submenus have an associated
java.awt.Menu. These are not utilized when the Menu is used within an
IFC View-based structure.
You generally create a new Menu and add MenuItems to it, configuring them
with submenus as appropriate. The following code creates a Menu with a
single MenuItem containing a single-item submenu:
menu = new Menu(true);
menuItem = menu.addItemWithSubmenu("Menu One");
menuItem.submenu().addItem("Item One", command, target);
Once a Menu structure is created, it can be added to a MenuView within
its Constructor method, or by calling setMenu on an existing
MenuView. This MenuView can then be added to an InternalWindow or
ExternalWindow with setMenuView. Additionally, you can add
this Menu directly to an ExternalWindow with setMenu, and
this will create an AWT-based native Menu on the top edge of the
Window. The following code adds the same Menu created above to an
existing ExternalWindow through both mechanisms:
externalWindow.setMenu(menu);
menuView = new MenuView(menu);
menuView.sizeToMinSize();
externalWindow.setMenuView(menuView);
Note: The Menu class does not support the insertion of a
submenu-less MenuItem into a top-level AWT-based Menu.
- See Also:
- MenuItem, MenuView
Constructors
.Menu
public Menu()
- Constructs a Menu.
This Menu will be top-level by default.
.Menu
public Menu(boolean isTopLevel)
- Constructs a Menu.
If isTopLevel is true, this Menu will be a top-level
Menu.
This denotation is critical for AWT-based native Menus, and is
not necessary with IFC View-based Menus.
Methods
public void setPrototypeItem(MenuItem prototype)
- Sets the prototype MenuItem for this Menu. Whenever the Menu needs a
new MenuItem, it clones the prototype MenuItem.
public MenuItem prototypeItem()
- Returns the Menu's prototype MenuItem.
- See Also:
- setPrototypeItem
public void setBackgroundColor(Color color)
- Sets the Color drawn behind transparent MenuItems, and any area in
the Menu not covered by MenuItems. This has no effect on AWT-based
native Menus.
public Color backgroundColor()
- Returns the background color.
- See Also:
- setBackgroundColor
public void setBorder(Border aBorder)
- Sets the Menu's Border. The Menu draws this Border around its smaller
inactive state and around its window when a MenuItem's submenu is
active. You can customize a Menu's look by setting a different Border.
This has no effect on AWT-based native Menus.
public Border border()
- Returns the Menu's Border.
- See Also:
- setBorder
public void setTransparent(boolean flag)
- Sets the Menu to be transparent or opaque. This has no effect on
AWT-based native Menus.
public boolean isTransparent()
- Overridden to return true if the Menu is transparent.
- See Also:
- setTransparent
protected Menu createMenuAsSubmenu()
- Creates a new Menu for use as a MenuItem's submenu. Called by
addItemWithSubmenu(). Subclasses should override this method
to return a subclass instance.
public MenuItem addItemWithSubmenu(String title)
- Adds a new MenuItem, containing a submenu, to the end of this
Menu, with title title.
public MenuItem addItem(String title,
String command,
Target target)
- Adds a new MenuItem to the end of this Menu, with title title,
command command and Target target.
public MenuItem addItem(String title,
String command,
Target target,
boolean isCheckbox)
- Adds a new MenuItem to the end of this Menu, with title title,
command command and Target target. If isCheckbox
is true, this adds a checkbox MenuItem.
public MenuItem addItem(String title,
char key,
String command,
Target target)
- Adds a new MenuItem to the end of this Menu, with title title,
command key equivalent key, command command and Target
target.
public MenuItem addItem(String title,
char key,
String command,
Target target,
boolean isCheckbox)
- Adds a new MenuItem to the end of this Menu, with title title,
command key equivalent key, command command and Target
target. If isCheckbox is true, this will add a checkbox
MenuItem.
public MenuItem addItemAt(String title,
char key,
String command,
Target target,
boolean isCheckbox,
int index)
- Adds a new MenuItem at the specified index in this Menu, with
title title,
command key equivalent key, command command and Target
target. If isCheckbox is true, this will add a checkbox
MenuItem.
public MenuItem addSeparator()
- Adds a separator line to this Menu at the current position.
public int indexOfItem(MenuItem item)
- Returns the index of the specified MenuItem.
public int itemCount()
- Returns the number of MenuItems this Menu contains.
public MenuItem itemAt(int index)
- Returns the MenuItem at index.
public void addItemAt(MenuItem menuItem,
int index)
- Adds the MenuItem menuItem at index.
public void removeItem(MenuItem menuItem)
- Removes menuItem from the Menu.
public void removeItemAt(int index)
- Removes the MenuItem at index.
public void replaceItemAt(int index,
MenuItem menuItem)
- Replaces the MenuItem at index with menuItem. This has
no effect on AWT-based native Menus.
public void replaceItem(MenuItem item,
MenuItem newItem)
- Replaces the MenuItem with the new MenuItem. This has no effect
on AWT-based native Menus.
public void performCommand(String command,
Object data)
- Called by mouseUp() in MenuView so that selected MenuItems
can send
their commands. The selected MenuItem is passed in as data,
so if it is null, no command is sent. You should never call this
method directly.
public boolean handleCommandKeyEvent(KeyEvent event)
- Examines all MenuItems for a command key equivalent. If the Menu
finds a match, this method performs the corresponding command and
returns true.
public void describeClassInfo(ClassInfo info)
- Describes the Menu class' information.
- See Also:
- describeClassInfo
public void encode(Encoder encoder) throws CodingException
- Encodes the Menu instance.
- See Also:
- encode
public void decode(Decoder decoder) throws CodingException
- Decodes the Menu instance.
- See Also:
- decode
public void finishDecoding() throws CodingException
- Finishes the Menu's unarchiving.
- See Also:
- finishDecoding
All Packages Class Hierarchy This Package Previous Next Index
Copyright © 1997 Netscape Communications Corporation. All rights reserved
Please send any comments or corrections to ifcfeedback@netscape.com
HTML generated on 21 Oct 1997