public class MenuItem extends Object
Modifier and Type | Class and Description |
---|---|
static class |
MenuItem.SectionHeader |
Modifier and Type | Field and Description |
---|---|
String |
action
The action String for the MenuItem.
|
static int |
Checked
A MenuItem modifier.
|
int |
customEdge |
Object |
data
Optional data to associate with the MenuItem.
|
Color |
defaultBackground |
static int |
Disabled
A MenuItem modifier.
|
FontChange |
fontChange
This will apply only for MenuItems that are text only.
|
static int |
HasCustomBackground
A MenuItem modifier.
|
int |
hotkey
An optional hotkey for the MenuItem.
|
int |
id
An optional ID for the item.
|
IImage |
image
If this is not null then this will be displayed instead of the label.
|
int |
indentLevel
This is -1 by default, which means that the index level should be calculated
automatically.
|
String |
label
The displayed label for the MenuItem.
|
static int |
MODIFIER_CHECKED |
static int |
MODIFIER_DISABLED |
static int |
MODIFIER_DONT_HIGHLIGHT |
static int |
MODIFIER_IS_SEPARATOR |
static int |
MODIFIER_SELECTED |
int |
modifiers
Modifiers for the MenuItem.
|
int |
originalIndex |
static int |
SectionHeader
A MenuItem modifier.
|
static int |
Selected
A MenuItem modifier.
|
static int |
Separator
A MenuItem modifier.
|
static int |
SoftKeyFixed
A MenuItem modifier.
|
StringList |
splitLabel
This may be used by a Control which displays the item.
|
Menu |
subMenu
This can be set to be a sub-menu for this item.
|
Constructor and Description |
---|
MenuItem() |
MenuItem(String text)
This creates the menu item with the action and label being equal to text.
|
MenuItem(String text,
IImage image)
This creates the menu item with the action and label being equal to text.
|
MenuItem(String text,
IImage icon,
boolean leaveText)
This creates a MenuItem using the ImageCache to load an icon for the item to be associated
with the text label.
|
MenuItem(String text,
int mods,
Menu sub)
This creates the menu item with the action and label being equal to text.
|
MenuItem(String label,
String action) |
Modifier and Type | Method and Description |
---|---|
boolean |
canBeSelected() |
boolean |
equals(Object what)
Returns if this object is considered equal to the other object.
|
Menu |
getActualSubMenu()
By default this returns subMenu, but it can instead return a different, dynamically created menu instead.
|
static MenuItem |
getIconized(String labelAndAction,
String iconName)
A convenience method to return a MenuItem that is the combination
of the label and specified icon.
|
static MenuItem |
getIconized(String labelAndAction,
String iconName,
FontMetrics fm) |
static MenuItem |
getIconized(String label,
String action,
String iconName)
A convenience method to return a MenuItem that is the combination
of the label and specified icon.
|
MenuItem |
iconize(String text,
IImage image,
boolean leaveText)
Set the label, hotkey and image for the item.
|
MenuItem |
iconize(String text,
IImage image,
boolean leaveText,
FontMetrics fm)
Set the label, hotkey and image for the item.
|
void |
paintCustomBackground(Graphics g,
int x,
int y,
int width,
int height)
This will only be called if the HasCustomBackground flag is set.
|
MenuItem |
set(String labelAndAction)
Set the action, label and hotkey of the MenuItem to be the specified parameter,
allowing the parameter to have a Hot Key encoded in it.
|
MenuItem |
setText(String labelAndAction)
Set the action and label of the MenuItem to be the specified parameter,
assuming that the parameter is pure text only with no Hot Key encoded in it.
|
String |
toString()
Return a String representation of this object.
|
public int originalIndex
public FontChange fontChange
public String label
public String action
public int modifiers
public Menu subMenu
public int id
public IImage image
public int hotkey
public Object data
public int indentLevel
public static int Disabled
public static int Separator
public static int Checked
public static int Selected
public static int SoftKeyFixed
public static int SectionHeader
public static int HasCustomBackground
public StringList splitLabel
public Color defaultBackground
public int customEdge
public static int MODIFIER_DISABLED
public static int MODIFIER_IS_SEPARATOR
public static int MODIFIER_CHECKED
public static int MODIFIER_SELECTED
public static int MODIFIER_DONT_HIGHLIGHT
public MenuItem()
public MenuItem(String text, int mods, Menu sub)
text
- The action and label for the menu item. This may have a hotkey embedded in it.mods
- Optional modifiers for the item.sub
- An optional sub-menu for the item.public MenuItem(String text)
text
- The action and label for the menu item. This may have a hotkey embedded in it.public MenuItem(String text, IImage image)
text
- The action and label for the menu item. This may have a hotkey embedded in it.image
- An image to use as the display for the item.public MenuItem(String text, IImage icon, boolean leaveText)
text
- The action and label for the menu item. This may have a hotkey embedded in it.icon
- an image for the menu item.leaveText
- if true then the image is added to the text (on the left),
if false then the entire image is used as the menu item and the text is ignored.public static MenuItem getIconized(String labelAndAction, String iconName)
labelAndAction
- the text to display.iconName
- the name of the icon to display with the text.public static MenuItem getIconized(String labelAndAction, String iconName, FontMetrics fm)
public static MenuItem getIconized(String label, String action, String iconName)
label
- the text to display.action
- the action for the item.iconName
- the name of the icon to display with the text.public MenuItem set(String labelAndAction)
labelAndAction
- The action and label for the menu item. This may have a hotkey embedded in it.public MenuItem setText(String labelAndAction)
labelAndAction
- The action and label for the menu item. This may have a hotkey embedded in it.public MenuItem iconize(String text, IImage image, boolean leaveText)
text
- The text for the label which may have a hotkey encoded within it.
If the action field is null when this is called it will also be set to the label.image
- The image which may be a small icon to be associated with the text or
it may be the entire display line.leaveText
- If this is true then it is assumed that the image is meant to be an
icon to be associated with the item.public MenuItem iconize(String text, IImage image, boolean leaveText, FontMetrics fm)
text
- The text for the label which may have a hotkey encoded within it.
If the action field is null when this is called it will also be set to the label.image
- The image which may be a small icon to be associated with the text or
it may be the entire display line.leaveText
- If this is true then it is assumed that the image is meant to be an
icon to be associated with the item.fm
- a FontMetrics to use.public String toString()
Object
public boolean equals(Object what)
Object
public boolean canBeSelected()
public void paintCustomBackground(Graphics g, int x, int y, int width, int height)
g
- x
- y
- width
- height
- public Menu getActualSubMenu()