|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.j4me.ui.components.Component
org.j4me.ui.components.MenuOption
public class MenuOption
The Menu
screen uses one of these MenuOption
components
for each menu choice.
The default implementation shows the choice number on the left, then the text for the choice, and an arrow on the right if it is a submenu. The text is clipped if it runs over a single line. This keeps all menu items the same height.
Menu
Field Summary |
---|
Fields inherited from class org.j4me.ui.components.Component |
---|
container, HIGHLIGHTED_BORDER_WIDTH |
Constructor Summary | |
---|---|
MenuOption(DeviceScreen choice)
Creates a new MenuOption component that encapsulates a
DeviceScreen . |
|
MenuOption(Menu choice,
boolean submenu)
Creates a new MenuOption component that encapsulates a
Menu . |
|
MenuOption(MenuItem choice)
Creates a new MenuOption component that encapsulates a
MenuItem . |
|
MenuOption(java.lang.String text,
DeviceScreen choice)
Creates a new MenuOption component that encapsulates a
DeviceScreen . |
Method Summary | |
---|---|
boolean |
acceptsInput()
Tells if this component accepts user input or not. |
java.lang.String |
getLabel()
|
protected int[] |
getPreferredComponentSize(Theme theme,
int viewportWidth,
int viewportHeight)
Returns the size of the menu choice. |
protected int[] |
getPreferredTextSize(Theme theme,
int viewportWidth,
int viewportHeight)
Returns the size of the menu text. |
protected int[] |
getSubmenuIndicatorSize(Theme theme,
int viewportWidth,
int viewportHeight)
Returns the size of the submenu indicator. |
protected void |
hideNotify()
An event raised whenever the component is removed from the screen. |
boolean |
isSubmenu()
|
void |
keyPressed(int key)
Called when the user presses any key. |
protected void |
paintComponent(javax.microedition.lcdui.Graphics g,
Theme theme,
int width,
int height,
boolean selected)
Paints a MenuOption . |
protected void |
paintText(javax.microedition.lcdui.Graphics g,
Theme theme,
int x,
int y,
int width,
int height,
boolean selected)
Paints a the text within the menu option component. |
void |
pointerPressed(int x,
int y)
Called when the pointer is pressed. |
void |
select()
Activates the command represented by this choice. |
void |
setLabel(java.lang.String label)
Explicitly sets the text shown in this menu option. |
protected void |
showNotify()
An event raised whenever the component is made visible on the screen. |
Methods inherited from class org.j4me.ui.components.Component |
---|
getHeight, getHorizontalAlignment, getPreferredSize, getScreen, getWidth, getX, getY, invalidate, isShown, keyReleased, keyRepeated, paint, paintRect, pointerDragged, pointerReleased, repaint, setHorizontalAlignment, visible |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public MenuOption(MenuItem choice)
MenuOption
component that encapsulates a
MenuItem
.
choice
- is the command that is represented by this component.public MenuOption(DeviceScreen choice)
MenuOption
component that encapsulates a
DeviceScreen
.
choice
- is the command that is represented by this component.public MenuOption(java.lang.String text, DeviceScreen choice)
MenuOption
component that encapsulates a
DeviceScreen
.
text
- is string that appears in the menu option.choice
- is the command that is represented by this component.public MenuOption(Menu choice, boolean submenu)
MenuOption
component that encapsulates a
Menu
.
choice
- is the command that is represented by this component.submenu
- when true
indicates this is a submenu of the
current menu.Method Detail |
---|
public boolean isSubmenu()
true
if this choice represents a submenu;
false
otherwise.public void setLabel(java.lang.String label)
MenuItem
or the title
of the DeviceScreen
. To clear explicitly set text pass
in null
.
label
- is the text that will appear for this menu item.
If null
the MenuItem.getText()
or
DeviceScreen.getTitle()
will be used.public java.lang.String getLabel()
null
.public void select()
Menu
class will call this method when the user selects this choice.
protected void showNotify()
paintComponent
method.
showNotify
in class Component
protected void hideNotify()
hideNotify
in class Component
protected void paintComponent(javax.microedition.lcdui.Graphics g, Theme theme, int width, int height, boolean selected)
MenuOption
. On the left is the choice number in
a box. The middle has the text for the choice. If it is a submenu
the right has an arrow.
paintComponent
in class Component
g
- is the Graphics
object to paint with.theme
- is the application's theme used to paint the menu item.width
- is the width of the menu item area in pixels.height
- is the height of the menu item area in pixels.selected
- is true
if this is the currently highlighted
menu choice.Component.paintComponent(javax.microedition.lcdui.Graphics, org.j4me.ui.Theme, int, int, boolean)
protected void paintText(javax.microedition.lcdui.Graphics g, Theme theme, int x, int y, int width, int height, boolean selected)
g
- is the Graphics
object to paint with.theme
- is the application's theme used to paint the menu item.x
- is the left of the text area.y
- is the top of the text area.width
- is the width of the menu item area in pixels.height
- is the height of the menu item area in pixels.selected
- is true
if this is the currently highlighted
menu choice.paintComponent(Graphics, Theme, int, int, boolean)
protected int[] getPreferredComponentSize(Theme theme, int viewportWidth, int viewportHeight)
getPreferredComponentSize
in class Component
theme
- is the application's Theme
.viewportWidth
- is the width of the viewable area, in pixels,
the component can use.viewportHeight
- is the height of the viewable area, in pixels,
the component can use.
Component.getPreferredComponentSize(org.j4me.ui.Theme, int, int)
protected int[] getPreferredTextSize(Theme theme, int viewportWidth, int viewportHeight)
theme
- is the application's Theme
.viewportWidth
- is the width of the screen in pixels.viewportHeight
- is the height of the screen in pixels.
protected int[] getSubmenuIndicatorSize(Theme theme, int viewportWidth, int viewportHeight)
theme
- is the application's Theme
.viewportWidth
- is the width of the screen in pixels.viewportHeight
- is the height of the screen in pixels.
public boolean acceptsInput()
Component
The default implementation returns false
. Override this method
to return true
if the component accepts input.
acceptsInput
in class Component
true
because this component accepts user input.public void keyPressed(int key)
keyPressed
in class Component
key
- is code of the key that was pressed.Component.keyPressed(int)
public void pointerPressed(int x, int y)
pointerPressed
in class Component
x
- is the horizontal location where the pointer was pressed
relative to the top-left corner of the component.y
- is the vertical location where the pointer was pressed
relative to the top-left corner of the component.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |