Abstract Class MenuComponent in Java

0
186
Spread the love
  • 24
  • 34
  • 14
  • 12
  •  
  •  
  •  
  • 12
  •  
  •  
    96
    Shares

Abstract Class MenuComponent in Java

The abstract class MenuComponent is the superclass of all menu related components. We never need to instantiate a MenuComponent directly. setFont() specifies the font to be used for all text within the menu component.

The structure of Abstract Class MenuComponent is given as:


public abstract class java.awt.MenuComponent extends java.lang.Object implements java.io.Serializable{
//constrcutor:
public MenuComponent();
//methods:
public final void dispatchEvent(AWTEvent e);
public Font getFont();
public String getName();
public MenuContainer getParent();
public MenuComponentPeer getPeer();
public boolean postEvent(Event evt);
protected String paramString();
protected void processEvent(AWTEvent e);
public void removeNotify();
public void setFont(Font f);
public String toString();
public void setName(String name);
} 

The details of the class structure are given as follows:

public final void dispatchEvent (AWTEvent e);

public final void dispatchEvent (AWTEvent e) method instructs the menu component to deal with the AWTEvent e.

Parameter
e – The AWTEvent to process.

public Font getFont();

public Font getFont() method returns the font for the current MenuComponent.

This method returns the font for the current MenuComponent.

public String getName();

public String getName() method returns the name for the current MenuComponent.

This method returns the name for the current MenuComponent.

public MenuContainer getParent();

public MenuContainer getParent() method returns the parent MenuContainer for the MenuComponent.

This method returns the parent MenuContainer for the MenuComponent.

public MenuComponentPeer getPeer();

public MenuComponentPeer getPeer() method returns a reference to the MenuComponent’s peer.

This method returns a reference to the MenuComponent’s peer.

public boolean postEvent (Event e);

public boolean postEvent (Event e) method instructs the Frame that contains the MenuBar containing the MenuComponent to deal with Event.

This method returns the ignored for menus.

Parameter
e – Event instance to post to component.

public void removeNotify();

public void removeNotify() method removes peer of MenuComponent’s subclass.

public void setFont (Font f);

public void setFont (Font f) method changes the font of the label of the MenuComponent.

Parameter
f – New font for MenuComponent.

public void setName (String name);

public void setName (String name) method changes the name of the MenuComponent.

Parameter
name – New name for MenuComponent.

public String toString();

public String toString() method returns a string representation of the MenuComponent object.

This method returns a string representation of the MenuComponent object.

protected String paramString();

protected String paramString() method is a helper method for toString() to generate string of current settings.

This method returns the String with current settings of MenuComponent.

protected void processEvent (AWTEvent e);

protected void processEvent (AWTEvent e) method accepts a low-level AWTEvents for processing.

Parameter
e – The event to process.

Don't miss out!
Subscribe To Newsletter

Receive top technical news, lesson ideas, travel tips and more!

Invalid email address
Give it a try. You can unsubscribe at any time.

Spread the love
  • 24
  • 34
  • 14
  • 12
  •  
  •  
  •  
  • 12
  •  
  •  
    96
    Shares

LEAVE A REPLY

Please enter your comment!
Please enter your name here