Allows the user to select one or more objects from a list.
CAVEAT
A list in a form has special implications to take care of:
Problem with a form request
is, that we should fire the selection change events not until the states
of all components are consistent. Unfortunately we cannot avoid events
before that
entirely. Problem is, that we use Swing Models for selection and they
don't know anything about asynchronous state change. They will fire their
events just after we set a state. But inside a form we have to change
many states of many components, all at once. And events should arise
first, after we set the new state of all components. So as a trade-off we
decided to use the setValueIsAdjusting in the ListSelectionModel as an
indicator,
if components are consistent. That is, if you get an SelectionEvent with
getValueIsAdjusting true, you cannot be sure, that component states are
consistent, so don't use that events. But you will get an event without
isValueAdjusting. You can work with that event. If you want to avoid that
problem, just use the selection events from the list itself, register your
listener at SList rather than at the ListSelectionModel...
author: Holger Engels author: Armin Haaf See Also:javax.swing.ListModel See Also:SDefaultListModel See Also:javax.swing.ListSelectionModel See Also:SListCellRenderer
If you want to receive immedate an event when the user clicks a new item
on the client side you have to register additionally a Java script listener
which triggers a form submit.
fireSelectionValueChanged(int firstIndex, int lastIndex, boolean isAdjusting) This method notifies all ListSelectionListeners that
the selection model has changed.
protected void
fireViewportChanged(boolean horizontal) Notifies all listeners that have registered interest for notification
on changes to this scrollable's viewport in the specified direction.
Add a listener to the list that's notified each time a change
to the selection occurs.
If you want to receive immedate an event when the user clicks a new item
on the client side you have to register additionally a Java script listener
which triggers a form submit. combobox.addScriptListener(ListCG.JS_ON_CHANGE_SUBMIT) Parameters: listener - A ListSelectionListener to be added See Also:SList.getSelectionModel
addSelectionInterval
public void addSelectionInterval(int anchor, int lead)(Code)
Notifies all listeners that have registered interest for notification
on changes to this scrollable's viewport in the specified direction.
See Also:EventListenerList
Returns an array of all the ListSelectionListeners added
to this JList with addListSelectionListener().
all of the ListSelectionListener added since: 1.4
Return the values of the selected cells.
Returns only the selected elements which are in the model.
If the selection model indices a selection outside the the datamodel it is ignored
the selected values See Also:SList.isSelectedIndex See Also:SList.getModel See Also:SList.addListSelectionListener
Return the preferred number of visible rows. If rendered as a form
component it is used for the size-attribute.
the preferred number of rows to display See Also:SList.setVisibleRowCount
Remove a listener from the list that's notified each time a
change to the selection occurs.
Parameters: listener - The ListSelectionListener to remove. See Also:SList.addListSelectionListener See Also:SList.getSelectionModel
removeSelectionInterval
public void removeSelectionInterval(int index0, int index1)(Code)
Sets the renderer that's used to write out each cell in the list.
Parameters: cellRenderer - the SListCellRenderer that paints list cellsdescription: The component used to draw the cells. See Also:SList.getCellRenderer
setEpochCheckEnabled
public void setEpochCheckEnabled(boolean epochCheckEnabled)(Code)
A convenience method that constructs a ListModel from an array of Objects
and then applies setModel to it.
Parameters: listData - an array of Objects containing the items to displayin the list See Also:SList.setModel
A convenience method that constructs a ListModel from a List
and then applies setModel to it.
Parameters: listData - a Vector containing the items to display in the list See Also:SList.setModel
Sets the model
Parameters: model - the ListModel that provides the list of itemsdescription: The object that contains the data to be shownin the list. See Also:SList.getModel
public void setSelectionMode(int selectionMode)(Code)
Allow / permit multiple selection
SINGLE_SELECTION
Only one list index can be selected at a time.
MULTIPLE_INTERVAL_SELECTION
Multiple items can be selected.
Parameters: selectionMode - single or multiple selectionsenum: SINGLE_SELECTION ListSelectionModel.SINGLE_SELECTIONMULTIPLE_INTERVAL_SELECTION ListSelectionModel.MULTIPLE_INTERVAL_SELECTION See Also:SList.getSelectionMode
Set the selectionModel for the list.
The selection model keeps track of which items are selected.
description: The selection model, recording which cells are selected.
See Also:SList.getSelectionModel
public void setVisibleRowCount(int visibleRowCount)(Code)
Set the preferred number of rows in the list that can be displayed
without a scollbar.
The default value of this property is 8.
Parameters: visibleRowCount - the preferred number of visible rowsdescription: The preferred number of cells that can be displayed without a scrollbar. See Also:SList.getVisibleRowCount