[Chapter 19] MenuComponent

#

| Chapter 19 java.awt Reference |

# MenuComponent

## Name

MenuComponent

##

## Description

The abstract `MenuComponent` class represents the parent of all menu GUI components.

## Class Definition

    public abstract class java.awt.MenuComponent
        extends java.lang.Object
        implements java.io.Serializable {

      // Instance Methods
      public final void dispatchEvent (AWTEvent e);
      public Font getFont();
      public String getName();
      public MenuContainer getParent();
      public MenuComponentPeer getPeer();
      public boolean postEvent (Event e);
      public void removeNotify();
      public void setFont (Font f);
      public void setName (String name);
      public String toString();

      // Protected Instance Methods
      protected String paramString();
      protected void processEvent (AWTEvent e);
    }

## Instance Methods

### dispatchEvent

#### public final void dispatchEvent (AWTEvent e)

Parameters

  e

    The `AWTEvent` to process.

Description

  Tells the menu component to deal with the `AWTEvent e`.

### getFont

#### public Font getFont()

Returns

  The font for the current `MenuComponent`.

### getName

#### public Font getName()

Returns

  The name for the current `MenuComponent`.

### getParent

#### public MenuContainer getParent()

Returns

  The parent `MenuContainer` for the `MenuComponent`.

### getPeer

#### public MenuComponentPeer getPeer()

Returns

  A reference to the `MenuComponent`'s peer.

### postEvent

#### public boolean postEvent (Event e)

Parameters

  e

    `Event` instance to post to component.

Returns

  Ignored for menus.

Description

  Tells the `Frame` that contains the `MenuBar` containing the `MenuComponent` to deal with `Event`.

### removeNotify

#### public void removeNotify()

Description

  Removes peer of `MenuComponent`'s subclass.

### setFont

#### public void setFont (Font f)

Parameters

  f

    New font for `MenuComponent`.

Description

  Changes the font of the label of the `MenuComponent`.

### setName

#### public void setName (String name)

Parameters

  name

    New name for `MenuComponent`.

Description

  Changes the name of the `MenuComponent`.

### toString

#### public String toString()

Returns

  A string representation of the `MenuComponent` object.

  Overrides

    `Object.toString()`

## Protected Instance Methods

### paramString

#### protected String paramString()

Returns

  String with current settings of `MenuComponent`.

Overrides

  `Component.paramString()`

Description

  Helper method for `toString()` to generate string of current settings.

### processEvent

#### protected void processEvent (AWTEvent e)

Parameters

  e

    The event to process.

Description

  Low-level `AWTEvent`s are passed to this method for processing.

## See Also

`Event`, `Font`, `MenuBar`, `MenuComponentPeer`, `MenuContainer`, `MenuItem`, `Object`, `Serializable`, `String`

MenuBar |  | MenuContainer