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); *Beta API*
    public MenuItem(String, char, String, Target, boolean); *Beta API*

    /* Methods
     */
    public Image checkedImage(); *Beta API*
    public Object clone();
    public String command();
    public char commandKey();
    public Object data();
    public void decode(Decoder);
    public void describeClassInfo(ClassInfo);
    public Color disabledColor(); *Beta API*
    protected void drawBackground(Graphics, Rect); *Beta API*
    public void drawInRect(Graphics, Rect, boolean); *Beta API*
    protected void drawSeparator(Graphics, Rect); *Beta API*
    protected void drawStringInRect(Graphics, String, Font, Rect, int); *Beta API*
    public void encode(Encoder);
    public void finishDecoding();
    public Font font();
    public boolean hasSubmenu();
    public Image image(); *Beta API*
    public boolean isEnabled();
    public boolean isSelected(); *Beta API*
    public boolean isSeparator(); *Beta API*
    public int minHeight(); *Beta API*
    public int minWidth(); *Beta API*
    public void processEvent(Event);
    public void requestDraw(); *Beta API*
    public Color selectedColor(); *Beta API*
    public Image selectedImage();
    public Color selectedTextColor(); *Beta API*
    public void sendCommand();
    public void setCheckedImage(Image); *Beta API*
    public void setCommand(String);
    public void setCommandKey(char);
    public void setData(Object);
    public void setDisabledColor(Color); *Beta API*
    public void setEnabled(boolean);
    public void setFont(Font);
    public void setImage(Image);
    public void setSelected(boolean); *Beta API*
    public void setSelectedColor(Color); *Beta API*
    public void setSelectedImage(Image); *Beta API*
    public void setSelectedTextColor(Color); *Beta API*
    public void setSeparator(boolean); *Beta API*
    public void setState(boolean); *Beta API*
    public void setSubmenu(Menu);
    public void setSupermenu(Menu);
    public void setTarget(Target);
    public void setTextColor(Color); *Beta API*
    public void setTitle(String);
    public void setUncheckedImage(Image); *Beta API*
    public boolean state(); *Beta API*
    public Menu submenu();
    public Menu supermenu();
    public Target target();
    public Color textColor(); *Beta API*
    public String title();
    public Image uncheckedImage(); *Beta API*
}
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) *Beta API* 
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) *Beta API* 
Constructs a MenuItem with the specified title, command key equivalent, command, and Target. If isCheckbox is true, this will be a checkbox MenuItem.

Methods

clone

  public Object clone()
Clones the MenuItem. Menu adds addtional items by cloning its prototype MenuItem.
Overrides:
clone in class Object

setSeparator

  public void setSeparator(boolean isSeparator) *Beta API* 
Sets this MenuItem to be a separator if isSeparator is true.

isSeparator

  public boolean isSeparator() *Beta API* 
Returns true if this MenuItem is a separator, false otherwise.

setData

  public void setData(Object data)
Sets the MenuItem's data, a storage place for arbitrary data associated with the MenuItem.

data

  public Object data()
Returns the MenuItem's data.
See Also:
setData

setSubmenu

  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.

submenu

  public Menu submenu()
Returns the MenuItem's submenu, null if it doesn't have one.

hasSubmenu

  public boolean hasSubmenu()
Returns true if this MenuItem has a submenu.
See Also:
setSubmenu

setSupermenu

  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.

supermenu

  public Menu supermenu()
Returns the MenuItem's supermenu.
See Also:
setSupermenu

setCommandKey

  public void setCommandKey(char key)
Sets the MenuItem's command key equivalent.

commandKey

  public char commandKey()
Returns the MenuItem's command key equivalent, '\0' if it doesn't have one.
See Also:
setCommandKey

setState

  public void setState(boolean aState) *Beta API* 
Sets the MenuItem's state if this is a checkbox MenuItem. This does nothing if this is a regular MenuItem.

state

  public boolean state() *Beta API* 
Returns the current state of the MenuItem. If this is not a checkbox MenuItem, returns false.

setImage

  public void setImage(Image theImage)
Sets the Image the MenuItem displays next to its title.
See Also:
setSelectedImage

image

  public Image image() *Beta API* 
Returns the Image the MenuItem displays next to its title.
See Also:
setImage

setSelectedImage

  public void setSelectedImage(Image theImage) *Beta API* 
Sets the Image the MenuItem displays next to its title when selected.
See Also:
setImage

selectedImage

  public Image selectedImage()
Returns the Image the MenuItem displays next to its title when selected.
See Also:
setSelectedImage

setCheckedImage

  public void setCheckedImage(Image theImage) *Beta API* 
Sets the Image displayed on the MenuItem if it is a checkbox MenuItem and its state is true.

checkedImage

  public Image checkedImage() *Beta API* 
Returns the Image displayed on the MenuItem if it is a checkbox MenuItem and its state is true.

setUncheckedImage

  public void setUncheckedImage(Image theImage) *Beta API* 
Sets the Image displayed on the MenuItem if it is a checkbox MenuItem and its state is false.

uncheckedImage

  public Image uncheckedImage() *Beta API* 
Returns the Image displayed on the MenuItem if it is a checkbox MenuItem and its state is false.

setSelectedColor

  public void setSelectedColor(Color color) *Beta API* 
Sets the color the MenuItem uses to draw its background when selected.

selectedColor

  public Color selectedColor() *Beta API* 
Returns the color the MenuItem uses to draw its background when selected.

setSelectedTextColor

  public void setSelectedTextColor(Color color) *Beta API* 
Sets the color the MenuItem uses to draw its foreground text when selected.

selectedTextColor

  public Color selectedTextColor() *Beta API* 
Returns the color the MenuItem uses to draw its foreground text when selected.

setTextColor

  public void setTextColor(Color color) *Beta API* 
Sets the color the MenuItem uses to draw its foreground text.

textColor

  public Color textColor() *Beta API* 
Returns the color the MenuItem uses to draw its foreground text.

setDisabledColor

  public void setDisabledColor(Color color) *Beta API* 
Sets the color the MenuItem uses to draw its text when disabled.

disabledColor

  public Color disabledColor() *Beta API* 
Returns the color the MenuItem uses to draw its text when disabled.

setSelected

  public void setSelected(boolean isSelected) *Beta API* 
Sets this MenuItem to be selected if isSelected is true, or unselected if false.

isSelected

  public boolean isSelected() *Beta API* 
Returns true if the MenuItem is selected.
See Also:
setSelected

setCommand

  public void setCommand(String newCommand)
Sets the MenuItem's command.

command

  public String command()
Returns the MenuItem's command.
See Also:
setCommand

setTarget

  public void setTarget(Target aTarget)
Sets the MenuItem's Target.

target

  public Target target()
Returns the MenuItem's Target.
See Also:
setTarget

processEvent

  public void processEvent(Event event)
Called by the EventLoop to process a selection event. Calls sendCommand().

sendCommand

  public void sendCommand()
Tells the MenuItem to send its command to its Target.
See Also:
setTarget

setTitle

  public void setTitle(String aString)
Sets the MenuItem's title.

title

  public String title()
Returns the MenuItem's title.

minHeight

  public int minHeight() *Beta API* 
Returns the minimum height required to display the MenuItem's title.

minWidth

  public int minWidth() *Beta API* 
Returns the minimum width required to display the MenuItem's title and Image, if any.

setEnabled

  public void setEnabled(boolean isEnabled)
Enables or disables the MenuItem. Disabled MenuItems cannot be selected and render their title using disabledColor.

isEnabled

  public boolean isEnabled()
Returns true if the MenuItem is enabled, false otherwise.
See Also:
setEnabled

setFont

  public void setFont(Font aFont)
Sets the Font used to display the MenuItem's title.

font

  public Font font()
Returns the Font used to display the MenuItem's title.
See Also:
setFont

requestDraw

  public void requestDraw() *Beta API* 
Convenience method for this MenuItem to redraw.

drawSeparator

  protected void drawSeparator(Graphics g,
                               Rect boundsRect) *Beta API* 
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.

drawBackground

  protected void drawBackground(Graphics g,
                                Rect boundsRect) *Beta API* 
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.

drawStringInRect

  protected void drawStringInRect(Graphics g,
                                  String title,
                                  Font titleFont,
                                  Rect textBounds,
                                  int justification) *Beta API* 
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.

drawInRect

  public void drawInRect(Graphics g,
                         Rect boundsRect,
                         boolean showsArrow) *Beta API* 
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.

describeClassInfo

  public void describeClassInfo(ClassInfo info)
Describes the MenuItem class' information.
See Also:
describeClassInfo

encode

  public void encode(Encoder encoder) throws CodingException
Archives the MenuItem instance.
See Also:
encode

decode

  public void decode(Decoder decoder) throws CodingException
Unarchives the MenuItem instance.
See Also:
decode

finishDecoding

  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 Apr 1997