public class IlxWComboBox
extends ilog.webui.dhtml.components.IlxWLabelWrapper
implements javax.swing.event.ListDataListener, java.awt.ItemSelectable, java.awt.event.ActionListener
The combo box component relies on a model, instance of
javax.swing.ComboBoxModel. It may be rendered in several
modes, determined by the value of the "mode" CSS style.
Possible values for the mode style are:
system: renders the combo box as a <select> HTML
element. This mode is not supported if the combo box has a renderer
or an editor. In this case, the component tries to render itself
in the "arrow" mode.link: renders the combo box as a hyperlink which, once
clicked pops up a menu just under the link. If the combo box has an
editor, this mode is not supported, and the component tries to
render itself in "arrow" mode. The combo box may also not support this mode
with some Web browsers (Netscape 3 & Netscape 4.7 for instance). In this
case, the component tries render itself in the "linkdialog"
mode.arrow: renders the combo box as Swing combo box:
the current renderer or the current editor is displayed, and an arrow
button is displayed to the right. A click on the arrow button pops up
a menu with the possible items. The combo box may not support this mode
with some Web browsers (Netscape 3 & Netscape 4.7 for instance). In this
case, the component tries render itself in the "arrowdialog"
mode.linkdialog: Same as the link mode but
a dialog box is popped up displaying the available items, instead of a
drop down list.arrowdialog: Same as the arrow mode but
a dialog box is popped up displaying the available items, instead of a
drop down list.system mode.
To set the current mode, you can either write a CSS style sheet:
ComboBox
{
mode: arrow;
}
... or dynamically set the style on the object:
myComboBox.getStyle().set("mode", "arrow");
IlxWComponent.DynamicStyleMap| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
ACTION_PROPERTY
The action bound property name.
|
protected java.lang.String |
actionCommand |
static java.lang.String |
EDITABLE_PROPERTY
The editable bound property name.
|
protected IlxWComboBoxEditor |
editor |
static java.lang.String |
EDITOR_PROPERTY
The editor bound property name.
|
static java.lang.String |
ENABLED_PROPERTY
The enabled bound property name.
|
protected boolean |
isEditable |
protected javax.swing.ComboBoxModel |
model |
static java.lang.String |
MODEL_PROPERTY
The model bound property name.
|
protected IlxWListCellRenderer |
renderer |
static java.lang.String |
RENDERER_PROPERTY
The renderer bound property name.
|
protected ilog.webui.dhtml.components.IlxWComboBox.ComboBoxUI |
ui
Access to allow another UI to the combo box (JSF)
|
listenerList| Constructor and Description |
|---|
IlxWComboBox()
Creates an
IlxWComboBox with a default data model. |
IlxWComboBox(javax.swing.ComboBoxModel aModel)
Creates an
IlxWComboBox that takes its items from an existing
ComboBoxModel. |
IlxWComboBox(java.lang.Object[] items)
Creates an
IlxWComboBox that contains the elements in the specified array. |
IlxWComboBox(java.util.Vector items)
Creates an
IlxWComboBox that contains the elements in the specified Vector. |
| Modifier and Type | Method and Description |
|---|---|
void |
actionPerformed(java.awt.event.ActionEvent e) |
void |
addActionListener(java.awt.event.ActionListener l)
Adds an action listener.
|
void |
addItemListener(java.awt.event.ItemListener listener)
Adds an item listener.
|
void |
configureEditor(IlxWComboBoxEditor anEditor,
java.lang.Object anItem)
Initializes the editor with the specified item.
|
void |
contentsChanged(javax.swing.event.ListDataEvent e) |
protected void |
fireActionEvent()
Notify all listeners that have registered interest for
notification on this event type.
|
protected void |
fireItemStateChanged(java.awt.event.ItemEvent e)
Notify all listeners that have registered interest for
notification on this event type.
|
IlxWAction |
getAction()
Gets the action that will be called when the user selects an item
in the combo box.
|
java.lang.String |
getActionCommand()
Returns the action command that is included in the event sent to
action listeners.
|
java.awt.event.ActionListener[] |
getActionListeners() |
IlxWComboBoxEditor |
getEditor()
Returns the editor used to render and edit the selected item in the
IlxWComboBox field. |
java.lang.Object |
getItemAt(int index)
Returns the list item at the specified index.
|
int |
getItemCount()
Returns the number of items in the list.
|
java.awt.event.ItemListener[] |
getItemListeners() |
javax.swing.ComboBoxModel |
getModel()
Returns the data model currently used by the
IlxWComboBox. |
java.lang.String |
getOnChangeJSAction() |
IlxWListCellRenderer |
getRenderer()
Returns the renderer used to display the selected item in the
IlxWComboBox field. |
int |
getSelectedIndex()
Returns the index of the currently selected item in the list.
|
java.lang.Object |
getSelectedItem()
Returns the currently selected item.
|
java.lang.Object[] |
getSelectedObjects()
Returns an array containing the selected item.
|
protected ilog.webui.dhtml.components.IlxWComboBox.ComboBoxUI |
getUI() |
protected ilog.webui.dhtml.components.IlxWComboBox.ComboBoxUI |
getUI(IlxWPort port) |
protected IlxWCSSRuleset |
getUserAgentRules()
Gets the "user-agent" CSS rules.
|
void |
intervalAdded(javax.swing.event.ListDataEvent e) |
void |
intervalRemoved(javax.swing.event.ListDataEvent e) |
boolean |
isEditable()
Returns True if the
IlxWComboBox is editable. |
boolean |
isEnabled()
Determines whether this component is enabled.
|
void |
notifyDependencies(IlxWPort port) |
protected void |
printComponent(IlxWPort port)
Prints the HTML code that will display the graphical
representation of this component.
|
void |
removeActionListener(java.awt.event.ActionListener l)
Removes an action listener.
|
void |
removeItemListener(java.awt.event.ItemListener listener)
Removes an item listener.
|
protected void |
selectedItemChanged()
This method is called when the selected item changes.
|
void |
setAction(IlxWAction action)
Sets the action that will be called when the user selects an item
in the combo box.
|
void |
setActionCommand(java.lang.String aCommand)
Sets the action command that should be included in the event
sent to action listeners.
|
void |
setEditable(boolean aFlag)
Determines whether the
IlxWComboBox field is editable. |
void |
setEditor(IlxWComboBoxEditor editor)
Sets the editor used to paint and edit the selected item in the
IlxWComboBox field. |
void |
setEnabled(boolean b)
Enables the combo box so that items can be selected.
|
void |
setModel(javax.swing.ComboBoxModel model)
Sets the data model that the
IlxWComboBox uses to obtain the list of
items. |
void |
setOnChangeJSAction(java.lang.String onChangeAction) |
void |
setRenderer(IlxWListCellRenderer renderer)
Sets the renderer that paints the item selected from the list in
the
IlxWComboBox field. |
void |
setSelectedIndex(int index)
Selects the item at index
anIndex. |
void |
setSelectedItem(java.lang.Object anObject)
Sets the selected item in the
IlxWComboBox by specifying the object in
the list. |
void |
update(org.w3c.dom.Element elt) |
getCSSModel, getIconPath, getIcoPath, getLabel, getText, setIconPath, setTextaddPropertyChangeListener, addPropertyChangeListener, detach, doPrint, firePropertyChange, firePropertyChange, getName, getRealHtmlTagName, getStyle, invalidate, isInvalidated, print, removePropertyChangeListener, removePropertyChangeListener, setName, validateadd, add, getAttribute, getAttributeNames, getComponent, getComponentCount, getComponentNamed, getComponents, getManager, getParent, indexOf, isAncestorOf, remove, remove, removeAll, removeAttribute, setAttribute, setAuthorRules, setFinalizerpublic static final java.lang.String MODEL_PROPERTY
public static final java.lang.String EDITOR_PROPERTY
public static final java.lang.String EDITABLE_PROPERTY
public static final java.lang.String ENABLED_PROPERTY
public static final java.lang.String ACTION_PROPERTY
public static final java.lang.String RENDERER_PROPERTY
protected javax.swing.ComboBoxModel model
protected IlxWListCellRenderer renderer
protected IlxWComboBoxEditor editor
protected boolean isEditable
protected java.lang.String actionCommand
protected ilog.webui.dhtml.components.IlxWComboBox.ComboBoxUI ui
public IlxWComboBox(javax.swing.ComboBoxModel aModel)
IlxWComboBox that takes its items from an existing
ComboBoxModel.aModel - The ComboBoxModel that provides the displayed list of
items.public IlxWComboBox(java.lang.Object[] items)
IlxWComboBox that contains the elements in the specified array.public IlxWComboBox(java.util.Vector items)
IlxWComboBox that contains the elements in the specified Vector.public IlxWComboBox()
IlxWComboBox with a default data model.
Use addItem to add items.public void setModel(javax.swing.ComboBoxModel model)
IlxWComboBox uses to obtain the list of
items.model - The combo box model that provides the displayed list of items.public javax.swing.ComboBoxModel getModel()
IlxWComboBox.public void setEditable(boolean aFlag)
IlxWComboBox field is editable.
An editable IlxWComboBox allows the user to type into the field or select an item
from the list to initialize the field, after which it can be edited.
A non editable IlxWComboBox 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 boolean isEditable()
IlxWComboBox is editable.true if the combo box can be edited; false otherwise.public void setRenderer(IlxWListCellRenderer renderer)
IlxWComboBox field.
The renderer is used if the IlxWComboBox is not
editable, otherwise the editor is used to render and edit the selected item.
The default renderer displays a string, obtained
by calling the selected object's toString method.
Other renderers can handle graphic images and composite items.
To display the selected item,
aRenderer.getListCellRendererComponent is called, passing
the list object and an index of -1.
renderer - The ListCellRenderer that displays the selected item.setEditor(ilog.webui.dhtml.components.IlxWComboBoxEditor)public IlxWListCellRenderer getRenderer()
IlxWComboBox field.public void setEditor(IlxWComboBoxEditor editor)
IlxWComboBox field.
The editor is used only if the receiving IlxWComboBox is editable.
If not editable, the combo box uses the renderer to render the selected
item.
editor - The IlxWComboBoxEditor that displays the selected item.setRenderer(ilog.webui.dhtml.components.IlxWListCellRenderer)public IlxWComboBoxEditor getEditor()
IlxWComboBox field.public void configureEditor(IlxWComboBoxEditor anEditor, java.lang.Object anItem)
anEditor - The IlxWComboBoxEditor that displays the list item in the
combo box field and allows it to be edited.anItem - The object to display and edit in the field.public void setSelectedItem(java.lang.Object anObject)
IlxWComboBox by specifying the object in
the list.
If anObject is in the list, the list displays with
anObject selected. If the object does not exist in the list,
the default data model selects the first item in the list.
anObject - The list object to select.public java.lang.Object getSelectedItem()
public void setSelectedIndex(int index)
anIndex.index - An int specifying the list item to select,
where 0 specifies the first item in the list.public int getSelectedIndex()
The result is not always defined if the IlxWComboBox box 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.
public void addItemListener(java.awt.event.ItemListener listener)
aListener will receive an event when
the selected item changes.
addItemListener in interface java.awt.ItemSelectablelistener - The item listener that is to be notified.public void removeItemListener(java.awt.event.ItemListener listener)
removeItemListener in interface java.awt.ItemSelectablelistener - The item listener to remove.public void addActionListener(java.awt.event.ActionListener l)
The listener will receive an action event the user finishes making a selection.
l - The action listener that is to be notified.public void removeActionListener(java.awt.event.ActionListener l)
l - The action listener to remove.public void setActionCommand(java.lang.String aCommand)
aCommand - A string containing the "command" that is sent
to action listeners. The same listener can then
do different things depending on the command it receives.public java.lang.String getActionCommand()
protected void fireItemStateChanged(java.awt.event.ItemEvent e)
EventListenerListpublic java.awt.event.ItemListener[] getItemListeners()
protected void fireActionEvent()
public java.awt.event.ActionListener[] getActionListeners()
protected void selectedItemChanged()
Its default implementation notifies the item listeners.
public java.lang.Object[] getSelectedObjects()
getSelectedObjects in interface java.awt.ItemSelectablepublic void actionPerformed(java.awt.event.ActionEvent e)
actionPerformed in interface java.awt.event.ActionListenerprotected ilog.webui.dhtml.components.IlxWComboBox.ComboBoxUI getUI(IlxWPort port)
port - The current port.protected ilog.webui.dhtml.components.IlxWComboBox.ComboBoxUI getUI()
public void intervalAdded(javax.swing.event.ListDataEvent e)
intervalAdded in interface javax.swing.event.ListDataListenerpublic void intervalRemoved(javax.swing.event.ListDataEvent e)
intervalRemoved in interface javax.swing.event.ListDataListenerpublic void contentsChanged(javax.swing.event.ListDataEvent e)
contentsChanged in interface javax.swing.event.ListDataListenerpublic void setEnabled(boolean b)
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 boolean isEnabled()
true if this component is enabled.setEnabled(boolean)public int getItemCount()
public java.lang.Object getItemAt(int index)
index - An int indicating the list position, where the first
item starts at zero.public IlxWAction getAction()
By default, this action is a Java action (IlxWJavaAction)
of which the perform method calls
setSelectedItem on the combo box.
If the given action is a Java action (IlxWJavaAction),
the argument array passed to the perform
method is a 1-length array containing the selected item.
If the given action is a JS action (IlxWJSAction),
the argument array passed when calling the associated function
is a 1-length array containing the string representation
of the selected item.
setAction(ilog.webui.dhtml.components.IlxWAction)public void setAction(IlxWAction action)
action - The action to perform when the user selects an item from the
list.getAction()public void setOnChangeJSAction(java.lang.String onChangeAction)
public java.lang.String getOnChangeJSAction()
public void update(org.w3c.dom.Element elt)
protected void printComponent(IlxWPort port) throws java.io.IOException
IlxWComponentIlxWComponent.print(ilog.webui.dhtml.IlxWPort) method.printComponent in class ilog.webui.dhtml.components.IlxWLabelWrapperjava.io.IOExceptionport - The port on which the component will be printed.IlxWComponent.print(ilog.webui.dhtml.IlxWPort)protected IlxWCSSRuleset getUserAgentRules()
IlxWContainersetAuthorRules method.
This method returns null by default but is intended
to be redefined by subclasses.
getUserAgentRules in class IlxWContainerIlxWContainer.setAuthorRules(ilog.webui.dhtml.IlxWCSSRuleset)public void notifyDependencies(IlxWPort port)
notifyDependencies in interface ilog.webui.dhtml.IlxWDependencyProvidernotifyDependencies in class IlxWComponent© Copyright IBM Corp. 1987, 2017