APIdia Launch Partner
Top Inners Fields Constructors Methods
sun.awt.X11

public Class XMenuItemPeer

extends Object
implements MenuItemPeer
Class Inheritance
All Implemented Interfaces
java.awt.peer.MenuItemPeer, java.awt.peer.MenuComponentPeer
Known Direct Subclasses
sun.awt.X11.XMenuPeer, sun.awt.X11.XCheckboxMenuItemPeer
Imports
java.awt.*, java.awt.peer.*, java.awt.event.*, sun.awt.AWTAccessor

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class

Field Summary

Modifier and TypeField and Description
private Rectangle
bounds

Rectangle occupied by menu item in container's coordinates.

private XBaseMenuWindow
container

Window that this item belongs to.

private static final int
private static final int
private MenuItem
target

Target MenuItem.

private XMenuItemPeer.TextMetrics
textMetrics

Text metrics are filled in calcTextMetrics function and reset in resetTextMetrics function.

private Point
textOrigin

Point in container's coordinate system used as origin by drawText.

Constructor Summary

AccessConstructor and Description
pack-priv
XMenuItemPeer(MenuItem target)

Construction

Method Summary

Modifier and TypeMethod and Description
pack-priv void
action(long
the timestamp of action event
when
,
int modifiers)

This function is invoked when the user clicks on menu item.

pack-priv XMenuItemPeer.TextMetrics
calcTextMetrics()

Returns width of item's shortcut label, 0 if item has no shortcut.

public void
dispose()

Implements java.awt.peer.MenuComponentPeer.dispose.

Implementation of interface methods

pack-priv Rectangle
getBounds()

returns bounds of item that were previously set by map() function

pack-priv XBaseMenuWindow
getContainer()

returns the window that this item belongs to

pack-priv String
pack-priv MenuItem
getTarget()

Access to target's fields

pack-priv String
pack-priv Font
pack-priv String
pack-priv MenuShortcut
pack-priv XMenuItemPeer.TextMetrics
getTextMetrics()

Returns text metrics of menu item.

pack-priv Point
getTextOrigin()

returns origin of item's text that was previously set by map() function

pack-priv boolean
isContainerShowing()

Returns true if container exists and is showing

pack-priv boolean
isSeparator()

This function should be overridden simply to return false in inherited classes.

pack-priv boolean
pack-priv boolean
isTargetItemEnabled()

Returns true if item and all its parents are enabled This function is used to fix 6184485: Popup menu is not disabled on XToolkit even when calling setEnabled (false)

pack-priv void
map(Rectangle
bounds of item in container's coordinates
bounds
,
Point
point for drawString in container's coordinates
textOrigin
)

Sets mapping of item to window.

pack-priv void
repaintIfShowing()

Repaints item if it is showing

pack-priv void
pack-priv void
setContainer(XBaseMenuWindow
the window that this item belongs to.
container
)

This function is called when filling item vectors in XMenuWindow & XMenuBar.

public void
setEnabled(boolean enabled)

Implements java.awt.peer.MenuItemPeer.setEnabled.

Enables or disables the menu item.

public void
setFont(Font font)

Implements java.awt.peer.MenuComponentPeer.setFont.

Sets the font for the menu component.

public void
setLabel(String label)

Implements java.awt.peer.MenuItemPeer.setLabel.

Sets the label to be displayed in this menu item.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

boundsback to summary
private Rectangle bounds

Rectangle occupied by menu item in container's coordinates. Filled by map(...) function from XBaseMenuWindow.map()

containerback to summary
private XBaseMenuWindow container

Window that this item belongs to.

SEPARATOR_HEIGHTback to summary
private static final int SEPARATOR_HEIGHT
SEPARATOR_WIDTHback to summary
private static final int SEPARATOR_WIDTH
targetback to summary
private MenuItem target

Target MenuItem. Note that 'target' member in XWindow is required for dispatching events. This member is only used for accessing its fields and firing ActionEvent & ItemEvent

textMetricsback to summary
private XMenuItemPeer.TextMetrics textMetrics

Text metrics are filled in calcTextMetrics function and reset in resetTextMetrics function. Text metrics contain calculated dimensions of various components of menu item.

textOriginback to summary
private Point textOrigin

Point in container's coordinate system used as origin by drawText.

Constructor Detail

XMenuItemPeerback to summary
pack-priv XMenuItemPeer(MenuItem target)

Construction

Method Detail

actionback to summary
pack-priv void action(long when, int modifiers)

This function is invoked when the user clicks on menu item.

Parameters
when:long

the timestamp of action event

calcTextMetricsback to summary
pack-priv XMenuItemPeer.TextMetrics calcTextMetrics()

Returns width of item's shortcut label, 0 if item has no shortcut. The height of shortcut can be determined from text dimensions. This function does not use any locks and is guaranteed to return some value (possibly actual, possibly expired)

disposeback to summary
public void dispose()

Implements java.awt.peer.MenuComponentPeer.dispose.

Implementation of interface methods

Annotations
@Override
getBoundsback to summary
pack-priv Rectangle getBounds()

returns bounds of item that were previously set by map() function

getContainerback to summary
pack-priv XBaseMenuWindow getContainer()

returns the window that this item belongs to

getShortcutTextback to summary
pack-priv String getShortcutText()
getTargetback to summary
pack-priv MenuItem getTarget()

Access to target's fields

getTargetActionCommandback to summary
pack-priv String getTargetActionCommand()
getTargetFontback to summary
pack-priv Font getTargetFont()
getTargetLabelback to summary
pack-priv String getTargetLabel()
getTargetShortcutback to summary
pack-priv MenuShortcut getTargetShortcut()
getTextMetricsback to summary
pack-priv XMenuItemPeer.TextMetrics getTextMetrics()

Returns text metrics of menu item. This function does not use any locks and is guaranteed to return some value (possibly actual, possibly expired)

getTextOriginback to summary
pack-priv Point getTextOrigin()

returns origin of item's text that was previously set by map() function

isContainerShowingback to summary
pack-priv boolean isContainerShowing()

Returns true if container exists and is showing

isSeparatorback to summary
pack-priv boolean isSeparator()

This function should be overridden simply to return false in inherited classes.

isTargetEnabledback to summary
pack-priv boolean isTargetEnabled()
isTargetItemEnabledback to summary
pack-priv boolean isTargetItemEnabled()

Returns true if item and all its parents are enabled This function is used to fix 6184485: Popup menu is not disabled on XToolkit even when calling setEnabled (false)

mapback to summary
pack-priv void map(Rectangle bounds, Point textOrigin)

Sets mapping of item to window.

Parameters
bounds:Rectangle

bounds of item in container's coordinates

textOrigin:Point

point for drawString in container's coordinates

See Also
XBaseMenuWindow#map()
repaintIfShowingback to summary
pack-priv void repaintIfShowing()

Repaints item if it is showing

resetTextMetricsback to summary
pack-priv void resetTextMetrics()
setContainerback to summary
pack-priv void setContainer(XBaseMenuWindow container)

This function is called when filling item vectors in XMenuWindow & XMenuBar. We need it because peers are created earlier than windows.

Parameters
container:XBaseMenuWindow

the window that this item belongs to.

setEnabledback to summary
public void setEnabled(boolean enabled)

Implements java.awt.peer.MenuItemPeer.setEnabled.

Doc from java.awt.peer.MenuItemPeer.setEnabled.

Enables or disables the menu item.

Annotations
@Override
setFontback to summary
public void setFont(Font font)

Implements java.awt.peer.MenuComponentPeer.setFont.

Doc from java.awt.peer.MenuComponentPeer.setFont.

Sets the font for the menu component.

Annotations
@Override
setLabelback to summary
public void setLabel(String label)

Implements java.awt.peer.MenuItemPeer.setLabel.

Doc from java.awt.peer.MenuItemPeer.setLabel.

Sets the label to be displayed in this menu item.

Annotations
@Override
sun.awt.X11 back to summary

pack-priv final Class XMenuItemPeer.TextMetrics

extends Object
implements Cloneable
Class Inheritance
All Implemented Interfaces
java.lang.Cloneable

Field Summary

Modifier and TypeField and Description
private int
private int
private Dimension

Constructor Summary

AccessConstructor and Description
pack-priv
TextMetrics(Dimension textDimension, int shortcutWidth, int textBaseline)

Method Summary

Modifier and TypeMethod and Description
public Object
clone()

Overrides java.lang.Object.clone.

Creates and returns a copy of this object.

pack-priv int
pack-priv int
pack-priv Dimension
Inherited from java.lang.Object:
equalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

shortcutWidthback to summary
private int shortcutWidth
textBaselineback to summary
private int textBaseline
textDimensionback to summary
private Dimension textDimension

Constructor Detail

TextMetricsback to summary
pack-priv TextMetrics(Dimension textDimension, int shortcutWidth, int textBaseline)

Method Detail

cloneback to summary
public Object clone()

Overrides java.lang.Object.clone.

Doc from java.lang.Object.clone.

Creates and returns a copy of this object. The precise meaning of "copy" may depend on the class of the object. The general intent is that, for any object x, the expression:

x.clone() != x
will be true, and that the expression:
x.clone().getClass() == x.getClass()
will be true, but these are not absolute requirements. While it is typically the case that:
x.clone().equals(x)
will be true, this is not an absolute requirement.

By convention, the returned object should be obtained by calling super.clone. If a class and all of its superclasses (except Object) obey this convention, it will be the case that x.clone().getClass() == x.getClass().

By convention, the object returned by this method should be independent of this object (which is being cloned). To achieve this independence, it may be necessary to modify one or more fields of the object returned by super.clone before returning it. Typically, this means copying any mutable objects that comprise the internal "deep structure" of the object being cloned and replacing the references to these objects with references to the copies. If a class contains only primitive fields or references to immutable objects, then it is usually the case that no fields in the object returned by super.clone need to be modified.

Annotations
@Override
getShortcutWidthback to summary
pack-priv int getShortcutWidth()
getTextBaselineback to summary
pack-priv int getTextBaseline()
getTextDimensionback to summary
pack-priv Dimension getTextDimension()