Class UIEditChoice
public class UIEditChoice extends UIChoice implements
IUITextListener
{
// Constructors
public UIEditChoice();
// Methods
public boolean action(Event e, Object obj);
public String getValueText();
public boolean gotFocus(Event e, Object o);
public boolean keyDown(Event e, int key);
public void layout();
public boolean lostFocus(Event e, Object o);
public void requestFocus();
public void setValueText(String s);
public void textValueChanged(UITextEvent te);
}
This class implements an editable choice control (combo box). A UIEditChoice object manages the following component in addition to those managed by a typical UIChoice control.
Component
|
Description
|
UIEdit
|
Displays the text of the choice control's currently selected item when the choice control has focus. The user can edit this text.
|
When a UIEditChoice object is first created, its associated UIMenuList object is empty. To add items to the list, call the add or addString method, inherited from the UIChoice class.
// Construct a UIEditChoice object.
UIEditChoice uiec = new UIEditChoice();
// Create an array of components. When items are added to
// the choice control, these array values will hold the
// components returned from addString.
IUIComponent comps[] = new IUIComponent[4];
// Create an array of strings and add each
// element to the choice control.
String colors[] = {"Mango", "Indigo", "Forest", "Heather"};
for (int i=0; i<4; i++)
comps[i] = uiec.addString(colors[i]);
// Initialize the control to display the first item.
uiec.setSelectedComp(comps[0]);
// Add the control to the container.
add(c);
The UIEditChoice class extends UIChoice and implements IUITextListener. By default, the text is centered and a UITextListener is added.
UIComponent
|
+--UIContainer
|
+--UIStateContainer
|
+--UIPanel
|
+--UIChoice
|
+--UIEditChoice
public UIEditChoice();
Creates an empty, single line, editable choice control. The control automatically adds a text event listener to the edit control.
Remarks:
Call the add or addString method to add items to the control's pop-up list.
public boolean action(Event e, Object obj);
Updates the editable choice control to display the currently selected item.
Return Value:
Returns false.
Parameter | Description |
e
| The event that was posted.
|
obj
| The object that posted the event.
|
Remarks:
An action event is generated when an item in the control's pop-up list is selected, and the pop-up is closed.
Overrides:
action(Event,Object) in UIChoice.
public String getValueText();
Retrieves the current text in the UIEditChoice control.
Return Value:
Returns a string containing the current text, or an empty string if there is no text.
Overrides:
getValueText() in UIChoice.
public boolean gotFocus(Event e, Object o);
Called when the component receives the input focus. The edit box becomes visible, and the display component is hidden.
Return Value:
Returns true if the event was handled; otherwise, returns false.
Parameter | Description |
e
| The event that was posted.
|
o
| The object that previously had the focus.
|
public boolean keyDown(Event e, int key);
Determines whether the SPACEBAR or the ENTER key is being pressed, and if so, sets the pressed state.
Return Value:
Returns true if the event was handled; otherwise, returns false.
Parameter | Description |
e
| The event posted to the button control.
|
key
| The key that has been pressed.
|
Remarks:
This method is called when the button has focus and a key is pressed. If the key being pressed is the SPACEBAR or the ENTER key, the button's pressed state is set. If the ESC key is being pressed, the button's pressed state is cleared.
Overrides:
keyDown(Event,int) in UIChoice.
public void layout();
Lays out the UIEditChoice control.
Return Value:
No return value.
Overrides:
layout() in UIChoice.
public boolean lostFocus(Event e, Object o);
Called when the component loses the input focus. If the text in the edit box corresponds to an item in the editable choice control's pop-up menu, this item is now displayed.
Return Value:
Returns false.
Parameter | Description |
e
| The event that was posted.
|
o
| The object that posted the event.
|
public void requestFocus();
Responds to the control receiving input focus.
Return Value:
No return value.
Remarks:
requestFocus calls UIContainer.requestFocus.
public void setValueText(String s);
Sets the text in the current UIEditChoice control to the value of the specified string.
Return Value:
No return value.
Parameter | Description |
s
| The string to set the text to.
|
Overrides:
setValueText(String) in UIChoice.
public void textValueChanged(UITextEvent te);
Used internally by the editable choice control to determine if the text of the UIEdit control has changed.
Return Value:
No return value.
Parameter | Description |
te
| The text event that was posted.
|