| Method from java.awt.MenuComponent Detail: |
String constructComponentName() {
return null; // For strict compliance with prior platform versions, a MenuComponent
// that doesn't set its name should return null from
// getName()
}
Constructs a name for this MenuComponent.
Called by getName when the name is null. |
public final void dispatchEvent(AWTEvent e) {
dispatchEventImpl(e);
}
Delivers an event to this component or one of its sub components. |
void dispatchEventImpl(AWTEvent e) {
EventQueue.setCurrentEventAndMostRecentTime(e);
Toolkit.getDefaultToolkit().notifyAWTEventListeners(e);
if (newEventsOnly ||
(parent != null && parent instanceof MenuComponent &&
((MenuComponent)parent).newEventsOnly)) {
if (eventEnabled(e)) {
processEvent(e);
} else if (e instanceof ActionEvent && parent != null) {
e.setSource(parent);
((MenuComponent)parent).dispatchEvent(e);
}
} else { // backward compatibility
Event olde = e.convertToOld();
if (olde != null) {
postEvent(olde);
}
}
}
|
boolean eventEnabled(AWTEvent e) {
return false;
}
|
final AccessControlContext getAccessControlContext() {
if (acc == null) {
throw new SecurityException(
"MenuComponent is missing AccessControlContext");
}
return acc;
}
|
int getAccessibleChildIndex(MenuComponent child) {
return -1; // Overridden in subclasses.
}
Gets the index of the child within this MenuComponent. |
public AccessibleContext getAccessibleContext() {
return accessibleContext;
}
Gets the AccessibleContext associated with
this MenuComponent.
The method implemented by this base class returns null.
Classes that extend MenuComponent
should implement this method to return the
AccessibleContext associated with the subclass. |
int getAccessibleIndexInParent() {
MenuContainer localParent = parent;
if (!(localParent instanceof MenuComponent)) {
// MenuComponents only have accessible index when inside MenuComponents
return -1;
}
MenuComponent localParentMenu = (MenuComponent)localParent;
return localParentMenu.getAccessibleChildIndex(this);
}
Gets the index of this object in its accessible parent. |
AccessibleStateSet getAccessibleStateSet() {
AccessibleStateSet states = new AccessibleStateSet();
return states;
}
Gets the state of this object. |
public Font getFont() {
Font font = this.font;
if (font != null) {
return font;
}
MenuContainer parent = this.parent;
if (parent != null) {
return parent.getFont();
}
return null;
}
Gets the font used for this menu component. |
final Font getFont_NoClientCode() {
Font font = this.font;
if (font != null) {
return font;
}
// The MenuContainer interface does not have getFont_NoClientCode()
// and it cannot, because it must be package-private. Because of
// this, we must manually cast classes that implement
// MenuContainer.
Object parent = this.parent;
if (parent != null) {
if (parent instanceof Component) {
font = ((Component)parent).getFont_NoClientCode();
} else if (parent instanceof MenuComponent) {
font = ((MenuComponent)parent).getFont_NoClientCode();
}
}
return font;
}
|
public String getName() {
if (name == null && !nameExplicitlySet) {
synchronized(this) {
if (name == null && !nameExplicitlySet)
name = constructComponentName();
}
}
return name;
}
Gets the name of the menu component. |
public MenuContainer getParent() {
return getParent_NoClientCode();
}
Returns the parent container for this menu component. |
final MenuContainer getParent_NoClientCode() {
return parent;
}
|
public MenuComponentPeer getPeer() {
return peer;
} Deprecated! As - of JDK version 1.1,
programs should not directly manipulate peers.
|
protected final Object getTreeLock() {
return Component.LOCK;
}
Gets this component's locking object (the object that owns the thread
sychronization monitor) for AWT component-tree and layout
operations. |
protected String paramString() {
String thisName = getName();
return (thisName != null? thisName : "");
}
Returns a string representing the state of this
MenuComponent. This method is intended to be used
only for debugging purposes, and the content and format of the
returned string may vary between implementations. The returned
string may be empty but may not be null. |
public boolean postEvent(Event evt) {
MenuContainer parent = this.parent;
if (parent != null) {
parent.postEvent(evt);
}
return false;
} Deprecated! As - of JDK version 1.1, replaced by dispatchEvent .
Posts the specified event to the menu.
This method is part of the Java 1.0 event system
and it is maintained only for backwards compatibility.
Its use is discouraged, and it may not be supported
in the future. |
protected void processEvent(AWTEvent e) {
}
Processes events occurring on this menu component.
Note that if the event parameter is null
the behavior is unspecified and may result in an
exception. |
public void removeNotify() {
synchronized (getTreeLock()) {
MenuComponentPeer p = (MenuComponentPeer)this.peer;
if (p != null) {
Toolkit.getEventQueue().removeSourceEvents(this, true);
this.peer = null;
p.dispose();
}
}
}
Removes the menu component's peer. The peer allows us to modify the
appearance of the menu component without changing the functionality of
the menu component. |
public void setFont(Font f) {
font = f;
//Fixed 6312943: NullPointerException in method MenuComponent.setFont(Font)
MenuComponentPeer peer = (MenuComponentPeer)this.peer;
if (peer != null) {
peer.setFont(f);
}
}
Sets the font to be used for this menu component to the specified
font. This font is also used by all subcomponents of this menu
component, unless those subcomponents specify a different font.
Some platforms may not support setting of all font attributes
of a menu component; in such cases, calling setFont
will have no effect on the unsupported font attributes of this
menu component. Unless subcomponents of this menu component
specify a different font, this font will be used by those
subcomponents if supported by the underlying platform. |
public void setName(String name) {
synchronized(this) {
this.name = name;
nameExplicitlySet = true;
}
}
Sets the name of the component to the specified string. |
public String toString() {
return getClass().getName() + "[" + paramString() + "]";
}
Returns a representation of this menu component as a string. |