Class MenuItem
All Packages Class Hierarchy This Package Previous Next Index
Class MenuItem
public class netscape.application.MenuItem
extends java.lang.Object
implements netscape.util.Codable,
java.lang.Cloneable,
netscape.application.EventProcessor
{
/* Constructors
*/
public MenuItem();
public MenuItem(String, String, Target);
public MenuItem(String, char, String, Target);
public MenuItem(String, String, Target, boolean);
public MenuItem(String, char, String, Target, boolean);
/* Methods
*/
public Image checkedImage();
public Object clone();
public String command();
public char commandKey();
public Object data();
public void decode(Decoder);
public void describeClassInfo(ClassInfo);
public Color disabledColor();
protected void drawBackground(Graphics, Rect);
public void drawInRect(Graphics, Rect, boolean);
protected void drawSeparator(Graphics, Rect);
protected void drawStringInRect(Graphics, String, Font, Rect, int);
public void encode(Encoder);
public void finishDecoding();
public Font font();
public boolean hasSubmenu();
public Image image();
public boolean isEnabled();
public boolean isSelected();
public boolean isSeparator();
public int minHeight();
public int minWidth();
public void processEvent(Event);
public void requestDraw();
public Color selectedColor();
public Image selectedImage();
public Color selectedTextColor();
public void sendCommand();
public void setCheckedImage(Image);
public void setCommand(String);
public void setCommandKey(char);
public void setData(Object);
public void setDisabledColor(Color);
public void setEnabled(boolean);
public void setFont(Font);
public void setImage(Image);
public void setSelected(boolean);
public void setSelectedColor(Color);
public void setSelectedImage(Image);
public void setSelectedTextColor(Color);
public void setSeparator(boolean);
public void setState(boolean);
public void setSubmenu(Menu);
public void setSupermenu(Menu);
public void setTarget(Target);
public void setTextColor(Color);
public void setTitle(String);
public void setUncheckedImage(Image);
public boolean state();
public Menu submenu();
public Menu supermenu();
public Target target();
public Color textColor();
public String title();
public Image uncheckedImage();
}
Object subclass representing a single item in a Menu. MenuItems are used
as both wrappers for AWT-based native MenuItems as well as for
IFC View-based pure
java Menus. Their behavior is determined by whether or not a given Menu
that holds the MenuItem
is set directly on an ExternalWindow with setMenu, or if a MenuView
holding a Menu (with the MenuItem)
is added to a Window with setMenuView. A MenuItem stores a
reference to a java.awt.MenuItem, as well as implementing
drawInRect for use in MenuViews.
A MenuItem may or may not have a submenu. In general, you don't
create MenuItems yourself, but instead use Menu's addItem() and
addItemWithSubmenu() methods.
- See Also:
- Menu
Constructors
.MenuItem
public MenuItem()
- Constructs an empty MenuItem.
.MenuItem
public MenuItem(String title,
String command,
Target target)
- Constructs a MenuItem with the specified title, command, and
Target.
.MenuItem
public MenuItem(String title,
char key,
String command,
Target target)
- Constructs a MenuItem with the specified title, command key
equivalent, command, and Target.
.MenuItem
public MenuItem(String title,
String command,
Target target,
boolean isCheckbox)
- Constructs a MenuItem with the specified title, command, and Target.
If isCheckbox is true, this will be a checkbox MenuItem.
.MenuItem
public MenuItem(String title,
char key,
String command,
Target target,
boolean isCheckbox)
- Constructs a MenuItem with the specified title, command key
equivalent, command, and Target. If isCheckbox is true,
this will be a checkbox MenuItem.
Methods
public Object clone()
- Clones the MenuItem. Menu adds addtional items by cloning its
prototype MenuItem.
- Overrides:
- clone in class Object
public void setSeparator(boolean isSeparator)
- Sets this MenuItem to be a separator if isSeparator is true.
public boolean isSeparator()
- Returns true if this MenuItem is a separator, false
otherwise.
public void setData(Object data)
- Sets the MenuItem's data, a storage place for arbitrary data associated
with the MenuItem.
public Object data()
- Returns the MenuItem's data.
- See Also:
- setData
public void setSubmenu(Menu aMenu)
- Sets this MenuItem to have the specified submenu. Note that in
order for a Menu structure to work properly, MenuItems should be
added directly to Menus with addItem and
addItemWithSubmenur. It is not sufficient to create a
MenuItem and call setSubmenu with a given Menu. You should
not call this method directly.
public Menu submenu()
- Returns the MenuItem's submenu, null if it doesn't have one.
public boolean hasSubmenu()
- Returns true if this MenuItem has a submenu.
- See Also:
- setSubmenu
public void setSupermenu(Menu aMenu)
- Sets the MenuItem's supermenu. Note that in
order for a Menu structure to work properly, MenuItems should be
added directly to Menus with addItem and
addItemWithSubmenur. It is not sufficient to create a
MenuItem and call setSupermenu with a given Menu. You should
not call this method directly.
public Menu supermenu()
- Returns the MenuItem's supermenu.
- See Also:
- setSupermenu
public void setCommandKey(char key)
- Sets the MenuItem's command key equivalent.
public char commandKey()
- Returns the MenuItem's command key equivalent, '\0' if it doesn't have
one.
- See Also:
- setCommandKey
public void setState(boolean aState)
- Sets the MenuItem's state if this is a checkbox MenuItem. This does
nothing if this is a regular MenuItem.
public boolean state()
- Returns the current state of the MenuItem. If this is not a checkbox
MenuItem, returns false.
public void setImage(Image theImage)
- Sets the Image the MenuItem displays next to its title.
- See Also:
- setSelectedImage
public Image image()
- Returns the Image the MenuItem displays next to its title.
- See Also:
- setImage
public void setSelectedImage(Image theImage)
- Sets the Image the MenuItem displays next to its title when
selected.
- See Also:
- setImage
public Image selectedImage()
- Returns the Image the MenuItem displays next to its title when
selected.
- See Also:
- setSelectedImage
public void setCheckedImage(Image theImage)
- Sets the Image displayed on the MenuItem if it is a checkbox
MenuItem and its state is true.
public Image checkedImage()
- Returns the Image displayed on the MenuItem if it is a checkbox
MenuItem and its state is true.
public void setUncheckedImage(Image theImage)
- Sets the Image displayed on the MenuItem if it is a checkbox
MenuItem and its state is false.
public Image uncheckedImage()
- Returns the Image displayed on the MenuItem if it is a checkbox
MenuItem and its state is false.
public void setSelectedColor(Color color)
- Sets the color the MenuItem uses to draw its background when
selected.
public Color selectedColor()
- Returns the color the MenuItem uses to draw its background when
selected.
public void setSelectedTextColor(Color color)
- Sets the color the MenuItem uses to draw its foreground text when
selected.
public Color selectedTextColor()
- Returns the color the MenuItem uses to draw its foreground text when
selected.
public void setTextColor(Color color)
- Sets the color the MenuItem uses to draw its foreground text.
public Color textColor()
- Returns the color the MenuItem uses to draw its foreground text.
public void setDisabledColor(Color color)
- Sets the color the MenuItem uses to draw its text when disabled.
public Color disabledColor()
- Returns the color the MenuItem uses to draw its text when disabled.
public void setSelected(boolean isSelected)
- Sets this MenuItem to be selected if isSelected is
true, or unselected if false.
public boolean isSelected()
- Returns true if the MenuItem is selected.
- See Also:
- setSelected
public void setCommand(String newCommand)
- Sets the MenuItem's command.
public String command()
- Returns the MenuItem's command.
- See Also:
- setCommand
public void setTarget(Target aTarget)
- Sets the MenuItem's Target.
public Target target()
- Returns the MenuItem's Target.
- See Also:
- setTarget
public void processEvent(Event event)
- Called by the EventLoop to process a selection event. Calls
sendCommand().
public void sendCommand()
- Tells the MenuItem to send its command to its Target.
- See Also:
- setTarget
public void setTitle(String aString)
- Sets the MenuItem's title.
public String title()
- Returns the MenuItem's title.
public int minHeight()
- Returns the minimum height required to display the MenuItem's title.
public int minWidth()
- Returns the minimum width required to display the MenuItem's title
and Image, if any.
public void setEnabled(boolean isEnabled)
- Enables or disables the MenuItem. Disabled MenuItems cannot be
selected and render their title using disabledColor.
public boolean isEnabled()
- Returns true if the MenuItem is enabled, false otherwise.
- See Also:
- setEnabled
public void setFont(Font aFont)
- Sets the Font used to display the MenuItem's title.
public Font font()
- Returns the Font used to display the MenuItem's title.
- See Also:
- setFont
public void requestDraw()
- Convenience method for this MenuItem to redraw.
protected void drawSeparator(Graphics g,
Rect boundsRect)
- Called from drawInRect() to draw the MenuItem if it is
a separator. Subclasses can override this method to do custom
drawing. This method has no meaning for MenuItems that are being used
in AWT-based native Menus.
protected void drawBackground(Graphics g,
Rect boundsRect)
- Called from drawInRect() to draw the MenuItem's background.
Subclasses can override this method to draw custom backgrounds.
This method has no meaning for MenuItems that are being used
in AWT-based native Menus.
protected void drawStringInRect(Graphics g,
String title,
Font titleFont,
Rect textBounds,
int justification)
- Called from drawInRect() to draw the MenuItem's title.
Subclasses can override this method to draw the title string in a
special way. This method has no meaning for MenuItems that are
being used in AWT-based native Menus.
public void drawInRect(Graphics g,
Rect boundsRect,
boolean showsArrow)
- Called by Menu to draw the MenuItem. If the MenuItem is
transparent, its Menu will have already drawn its background. If
not, the MenuItem should entirely fill boundsRect. If
showsArrow is true and this MenuItem has a submenu, a
submenu arrow will be drawn on the right edge.
This method has no meaning for MenuItems that are being used
in AWT-based native Menus.
public void describeClassInfo(ClassInfo info)
- Describes the MenuItem class' information.
- See Also:
- describeClassInfo
public void encode(Encoder encoder) throws CodingException
- Archives the MenuItem instance.
- See Also:
- encode
public void decode(Decoder decoder) throws CodingException
- Unarchives the MenuItem instance.
- See Also:
- decode
public void finishDecoding() throws CodingException
- Finishes the MenuItem'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