|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectfds.micro.ui.Component
fds.micro.ui.ExclusiveChoice
This class implements an component that provide a way to select an exclusive choice between several ones.
You can choose the rendering type to use: Radio buttons or a field with buttons to change the value.
An object of this class is dedicated to be used within an object of fds.micro.ui.AbstractPanel sub-class (J2ME).
Warning: Use this class only if you want to have control on rendering. If possible, always prefer javax.microedition.lcdui.ChoiceGroup classe.
You can read below a typical use within a class that inherit fds.micro.ui.RowPanel:
Construction
... // Add an exclusive choice in field mode final String options = new String[] {"One", "Two", "Three", "Four", "Five"}; this.choice = new ExclusiveChoice(options, true); // Radio buttons this.choice.setMarkColor(255, 0, 0); // Red dot when an option is selected this.choice.setForeground(0, 0, 255); // Blue option labels this.choice.setFocusColor(0, 0, 255); // Blue focus color this.choice.setMaxCols(3); // Display options on 3 columns this.choice.setMaxRows(-1); // Use as many rows as necessary to display all options append(choice); ...Usage
... // Here we want to know which option is selected int selIndex = this.choice.getSelectedIndex(); switch(selIndex) { case 0: ... break; ... default: ... } ...
Field Summary |
Fields inherited from class fds.micro.ui.Component |
INTERN_BOTTOM_VALIGN, INTERN_CENTER_HALIGN, INTERN_CENTER_VALIGN, INTERN_LEFT_HALIGN, INTERN_RIGHT_HALIGN, INTERN_TOP_VALIGN |
Constructor Summary | |
ExclusiveChoice(java.lang.String[] labels)
Build an exclusive choice component rendered by radio buttons, and selects the first one. |
|
ExclusiveChoice(java.lang.String[] labels,
boolean radio)
Build an exclusive choice component and selects the first one. |
|
ExclusiveChoice(java.lang.String[] labels,
boolean radio,
int selectedIndex)
Build an exclusive choice component and selects the specified one. |
|
ExclusiveChoice(java.lang.String[] labels,
int selectedIndex)
Build an exclusive choice component rendered by radio buttons, and selects the specified one. |
Method Summary | |
void |
addValueChangeListener(ValueChangeListener listener)
Add a listener object that will receive events produced by this component when the value is changed. |
int |
getChoiceCount()
Get the number of possible choices. |
javax.microedition.lcdui.Font |
getFont()
Get the font used to display choice values. |
int |
getMaxCols()
Get the number of maximum columns for displaying radio buttons (a -1 value means no limit). |
int |
getMaxRows()
Get the number of maximum rows for displaying radio buttons (a -1 value means no limit). |
int |
getSelectedIndex()
Get the index of currently selected choice. |
java.lang.String |
getSelectedValue()
Get the text value of currently selected choice. |
int |
getXInset()
Get the number of pixels used to separate columns of radio buttons. |
int |
getYInset()
Get the number of pixels used to separate rows of radio buttons. |
boolean |
isBoxOpaque()
Get the check box opacity flag for box background (field entry zone, or radio button boxes). |
void |
keyPressed(int keyCode,
int gameAction)
Called to notify the component that a key is pressed. |
void |
pointerPressed(int xpos,
int ypos)
Called to notify the component that pointer device was pressed. |
void |
removeValueChangListener(ValueChangeListener listener)
Remove a listener. |
void |
setBoxBackground(int red,
int green,
int blue)
Set the color of the box background (radio circle or field box). |
void |
setBoxBackgroundOff(int red,
int green,
int blue)
Set the color of the box background (radio circle or field box) in case of the component is disabled. |
void |
setBoxColor(int red,
int green,
int blue)
Set the color of the box (radio circle or field box). |
void |
setBoxOpaque(boolean boxOpaque)
Set/reset the opacity flag for box background (field entry zone, or radio button boxes). |
void |
setFont(javax.microedition.lcdui.Font font)
Change the font used to display choice values. |
void |
setForeground(int red,
int green,
int blue)
Set the color used to draw the texts. |
void |
setForegroundOff(int red,
int green,
int blue)
Set the color used to draw the texts in case the component is disabled. |
void |
setMarkColor(int red,
int green,
int blue)
Set the color used to draw the selected mark (only used if rendered by radio buttons). |
void |
setMaxCols(int maxCols)
Change the number of maximum columns for displaying radio buttons. |
void |
setMaximumSize(int width,
int height)
Set the maximum size for this component. |
void |
setMaxRows(int maxRows)
Change the number of maximum rows for displaying radio buttons. |
void |
setSelectedIndex(int selectedIndex)
Change the currently selected choice. |
void |
setSelectedValue(java.lang.String value)
Change the currently selected value. |
void |
setXInset(int xInset)
Change the number of pixels used to separate columns of radio buttons. |
void |
setYInset(int yInset)
Change the number of pixels used to separate rows of radio buttons. |
Methods inherited from class fds.micro.ui.Component |
addFocusListener, addItemListener, equals, getHAlign, getHeight, getParent, getVAlign, getWidth, getX, getY, isDisabled, isHaveFocus, isHidden, isManageFocus, isOpaque, removeFocusListener, removeItemListener, setBackground, setDisabled, setFocusColor, setHAlign, setHidden, setLocation, setManageFocus, setOpaque, setVAlign |
Methods inherited from class java.lang.Object |
getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public ExclusiveChoice(java.lang.String[] labels)
labels
- Labels to be displayed as choices.public ExclusiveChoice(java.lang.String[] labels, boolean radio)
labels
- Labels to be displayed as choices.radio
- Must be true to display the choices as radio buttons, otherwise a field will be displayed.public ExclusiveChoice(java.lang.String[] labels, boolean radio, int selectedIndex)
labels
- Labels to be displayed as choices.radio
- Must be true to display the choices as radio buttons, otherwise a field will be displayed.selectedIndex
- The initially selected index.public ExclusiveChoice(java.lang.String[] labels, int selectedIndex)
labels
- Labels to be displayed as choices.selectedIndex
- The initially selected index.Method Detail |
public void addValueChangeListener(ValueChangeListener listener)
listener
- The listener to add.public int getChoiceCount()
public javax.microedition.lcdui.Font getFont()
public int getMaxCols()
public int getMaxRows()
public int getSelectedIndex()
public java.lang.String getSelectedValue()
public int getXInset()
public int getYInset()
public boolean isBoxOpaque()
public void keyPressed(int keyCode, int gameAction)
keyPressed
in class Component
keyCode
- The key code.gameAction
- Game action corresponding to the key code.public void pointerPressed(int xpos, int ypos)
pointerPressed
in class Component
xpos
- The X position of pointer on parent Canvas.ypos
- The Y position of pointer on parent Canvas.public void removeValueChangListener(ValueChangeListener listener)
listener
- The listener to remove.public void setBoxBackground(int red, int green, int blue)
red
- The red component of the color to set.green
- The green component of the color to set.blue
- The blue component of the color to set.public void setBoxBackgroundOff(int red, int green, int blue)
red
- The red component of the color to set.green
- The green component of the color to set.blue
- The blue component of the color to set.public void setBoxColor(int red, int green, int blue)
red
- The red component of the color to set.green
- The green component of the color to set.blue
- The blue component of the color to set.public void setBoxOpaque(boolean boxOpaque)
boxOpaque
- Must be true to fill box background.public void setFont(javax.microedition.lcdui.Font font)
font
- The font to set.public void setForeground(int red, int green, int blue)
red
- The red component of the color to set.green
- The green component of the color to set.blue
- The blue component of the color to set.public void setForegroundOff(int red, int green, int blue)
red
- The red component of the color to set.green
- The green component of the color to set.blue
- The blue component of the color to set.public void setMarkColor(int red, int green, int blue)
red
- The red component of the color to set.green
- The green component of the color to set.blue
- The blue component of the color to set.public void setMaxCols(int maxCols)
maxCols
- The number of maximum columns (a -1 value means no limit).public void setMaximumSize(int width, int height)
setMaximumSize
in class Component
width
- The maximum width.height
- The maximum height.public void setMaxRows(int maxRows)
maxRows
- The number of maximum rows (a -1 value means no limit).public void setSelectedIndex(int selectedIndex)
selectedIndex
- The index to set as selected one.public void setSelectedValue(java.lang.String value)
value
- The value to set. Must be an existing one, otherwise this method have no effect.public void setXInset(int xInset)
xInset
- The space (in pixels) between columns of radio buttons.public void setYInset(int yInset)
yInset
- The space (in pixels) between rows of radio buttons.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |