A component that combines a button or editable field and a drop-down list. The user can select a value from the drop-down list, which appears at the user's request. If you make the combo box editable, then the combo box includes an editable field into which the user can type a value.
JComboBox
use a JList
to be the drop-down list, so of course you can operate
list to do some thing.
By default JComboBox
can't count its preffered width accurately
like default JList, you have to set its preffered size if you want.
Or you make a not shared cell factory to it. see ListCellFactory
and JList
for details.
new JComboBox()
static public ON_ACT:String
public function setUI(ui:ComboBoxUI):Void
Description copied from Component
Sets the look and feel delegate for this component.
Component
subclasses generally override this method
to narrow the argument type. For example, in JSlider
:
public void setUI(SliderUI newUI) { super.setUI(newUI); }
Additionally Component
subclasses must provide a
getUI
method that returns the correct type. For example:
public SliderUI getUI() { return (SliderUI)ui; }
public function updateUI():Void
Description copied from Component
Resets the UI property to a value from the current look and feel.
Component
subclasses must override this method
like this:
public void updateUI() { setUI((SliderUI)UIManager.getUI(this); }
public function getUIClassID():String
Description copied from Component
Returns the UIDefaults
key used to
look up the name of the org.aswing.plaf.ComponentUI
class that defines the look and feel
for this component. Most applications will never need to
call this method. Subclasses of Component
that support
pluggable look and feel should override this method to
return a UIDefaults
key that maps to the
ComponentUI
subclass that defines their look and feel.
public function addActionListener(func:Function, obj:Object):Object
addChangeListener(func:Function)
addChangeListener(func:Function, obj:Object)
The ActionListener will receive an ActionEvent when a selection has been made. If the combo box is editable, then an ActionEvent will be fired when editing has stopped.
the listener added.
public function setMaximumRowCount(count:Number):Void
Sets the maximum number of rows the JComboBox
displays.
If the number of objects in the model is greater than count,
the combo box uses a scrollbar.
count | an integer specifying the maximum number of items to display in the list before using a scrollbar |
public function getMaximumRowCount():Number
Returns the maximum number of items the combo box can display without a scrollbar
an integer specifying the maximum number of items that are displayed in the list before using a scrollbar
public function getListCellFactory():ListCellFactory
the cellFactory for the popup List
public function setListCellFactory(newFactory:ListCellFactory):Void
This will cause all cells recreating by new factory.
newFactory | the new cell factory for the popup List |
public function setEditor(anEditor:ComboBoxEditor):Void
Sets the editor used to paint and edit the selected item in the
JComboBox
field. The editor is used both if the
receiving JComboBox
is editable and not editable.
anEditor | the ComboBoxEditor that
displays the selected item
|
public function getEditor():ComboBoxEditor
Returns the editor used to paint and edit the selected item in the
JComboBox
field.
the ComboBoxEditor
that displays the selected item
public function setEditable(aFlag:Boolean):Void
Determines whether the JComboBox
field is editable.
An editable JComboBox
allows the user to type into the
field or selected an item from the list to initialize the field,
after which it can be edited. (The editing affects only the field,
the list item remains intact.) A non editable JComboBox
displays the selected item in the field,
but the selection cannot be modified.
aFlag | a boolean value, where true indicates that the field is editable |
public function isEditable():Boolean
Returns true if the JComboBox
is editable.
By default, a combo box is not editable.
true if the JComboBox
is editable, else false
public function setEnabled(b:Boolean):Void
Enables the combo box so that items can be selected. When the combo box is disabled, items cannot be selected and values cannot be typed into its field (if it is editable).
b | a boolean value, where true enables the component and false disables it |
public function setListData(ld:Array):Void
set a array to be the list data, but array is not a List Mode. So when the array content was changed, you should call updateListView to update the JList(the list for combo box).But this is not a good way, its slow. So suggest you to create a ListMode eg. VectorListMode, When you modify ListMode, it will automatic update JList.
public function setPopupVisible(v:Boolean):Void
Sets the visibility of the popup, open or close.
public function isPopupVisible():Boolean
Determines the visibility of the popup.
true if the popup is visible, otherwise returns false
public function setSelectedItem(anObject:Object):Void
Sets the selected item in the combo box display area to the object in
the argument.
If anObject
is in the list, the display area shows
anObject
selected.
If anObject
is not in the list and the combo box is
uneditable, it will not change the current selection. For editable
combo boxes, the selection will change to anObject
.
ON_ACT
(addActionListener()
)events added to the combo box will be notified
when this method is called.
anObject | the list object to select; use null to
clear the selection
|
public function getSelectedItem():Object
Returns the current selected item.
If the combo box is editable, then this value may not have been in the list model.
the current selected Object
public function setSelectedIndex(anIndex:Number):Void
Selects the item at index anIndex
.
anIndex | an integer specifying the list item to select, where 0 specifies the first item in the list and -1 or greater than max index indicates empty selection |
public function getSelectedIndex():Number
Returns the first item in the list that matches the given item.
The result is not always defined if the JComboBox
allows selected items that are not in the list.
Returns -1 if there is no selected item or if the user specified
an item which is not in the list.
an integer specifying the currently selected list item, where 0 specifies the first item in the list; or -1 if no item is selected or if the currently selected item is not in the list
public function getItemCount():Number
Returns the number of items in the list.
an integer equal to the number of items in the list
public function getItemAt(index:Number):Object
Returns the list item at the specified index. If index
is out of range (less than zero or greater than or equal to size)
it will return undefined
.
index | an integer indicating the list position, where the first item starts at zero |
the Object
at that list position; or
undefined
if out of range