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); *Beta API*
public MenuItem addItem(String, char, String, Target);
public MenuItem addItem(String, char, String, Target, boolean); *Beta API*
public MenuItem addItemAt(String, char, String, Target, boolean, int); *Beta API*
public void addItemAt(MenuItem, int);
public MenuItem addItemWithSubmenu(String);
public MenuItem addSeparator(); *Beta API*
public Color backgroundColor(); *Beta API*
public Border border(); *Beta API*
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(); *Beta API*
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); *Beta API*
public void replaceItemAt(int, MenuItem); *Beta API*
public void setBackgroundColor(Color); *Beta API*
public void setBorder(Border); *Beta API*
public void setPrototypeItem(MenuItem);
public void setTransparent(boolean); *Beta API*
}
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
setPrototypeItem
public void setPrototypeItem(MenuItem prototype)
- Sets the prototype MenuItem for this Menu. Whenever the Menu needs a
new MenuItem, it clones the prototype MenuItem.
prototypeItem
public MenuItem prototypeItem()
- Returns the Menu's prototype MenuItem.
- See Also:
- setPrototypeItem
setBackgroundColor
public void setBackgroundColor(Color color) *Beta API*
- 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.
backgroundColor
public Color backgroundColor() *Beta API*
- Returns the background color.
- See Also:
- setBackgroundColor
setBorder
public void setBorder(Border aBorder) *Beta API*
- 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.
border
public Border border() *Beta API*
- Returns the Menu's Border.
- See Also:
- setBorder
setTransparent
public void setTransparent(boolean flag) *Beta API*
- Sets the Menu to be transparent or opaque. This has no effect on
AWT-based native Menus.
isTransparent
public boolean isTransparent() *Beta API*
- Overridden to return true if the Menu is transparent.
- See Also:
- setTransparent
createMenuAsSubmenu
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.
addItemWithSubmenu
public MenuItem addItemWithSubmenu(String title)
- Adds a new MenuItem, containing a submenu, to the end of this
Menu, with title title.
addItem
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.
addItem
public MenuItem addItem(String title,
String command,
Target target,
boolean isCheckbox) *Beta API*
- 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.
addItem
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.
addItem
public MenuItem addItem(String title,
char key,
String command,
Target target,
boolean isCheckbox) *Beta API*
- 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.
addItemAt
public MenuItem addItemAt(String title,
char key,
String command,
Target target,
boolean isCheckbox,
int index) *Beta API*
- 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.
addSeparator
public MenuItem addSeparator() *Beta API*
- Adds a separator line to this Menu at the current position.
indexOfItem
public int indexOfItem(MenuItem item)
- Returns the index of the specified MenuItem.
itemCount
public int itemCount()
- Returns the number of MenuItems this Menu contains.
itemAt
public MenuItem itemAt(int index)
- Returns the MenuItem at index.
addItemAt
public void addItemAt(MenuItem menuItem,
int index)
- Adds the MenuItem menuItem at index.
removeItem
public void removeItem(MenuItem menuItem)
- Removes menuItem from the Menu.
removeItemAt
public void removeItemAt(int index)
- Removes the MenuItem at index.
replaceItemAt
public void replaceItemAt(int index,
MenuItem menuItem) *Beta API*
- Replaces the MenuItem at index with menuItem. This has
no effect on AWT-based native Menus.
replaceItem
public void replaceItem(MenuItem item,
MenuItem newItem) *Beta API*
- Replaces the MenuItem with the new MenuItem. This has no effect
on AWT-based native Menus.
performCommand
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.
handleCommandKeyEvent
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.
describeClassInfo
public void describeClassInfo(ClassInfo info)
- Describes the Menu class' information.
- See Also:
- describeClassInfo
encode
public void encode(Encoder encoder) throws CodingException
- Encodes the Menu instance.
- See Also:
- encode
decode
public void decode(Decoder decoder) throws CodingException
- Decodes the Menu instance.
- See Also:
- decode
finishDecoding
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 Apr 1997