JList

Extends
JComponent
Methods
43
Fields
4

Getting one

JList.new(…)

Methods

MethodReturnsDescription
getSelectedIndex()numberThe first selected row, or -1.
setSelectedIndex(number)()Selects that row alone; a row at or past the model's size, or -1, does nothing. Below -1 raises.
getSelectedIndices(){number}The selected rows, in increasing order (0-based).
setSelectedIndices({number})()Selects these rows (those at or past the model's size are ignored).
isSelectedIndex(number)booleanWhether index is selected.
isSelectionEmpty()booleanWhether nothing is selected.
clearSelection()()Selects nothing; the lead and anchor stay.
getMinSelectionIndex()numberThe smallest selected row, or -1.
getMaxSelectionIndex()numberThe largest selected row, or -1.
getLeadSelectionIndex()numberThe row the last selection change ended at, or -1.
getAnchorSelectionIndex()numberThe row the last selection change started from, or -1.
setSelectionInterval(number, number)()Selects the rows index0 to index1 (only index1 in SINGLE_SELECTION).
addSelectionInterval(number, number)()Adds the rows index0 to index1 to the selection.
removeSelectionInterval(number, number)()Removes the rows index0 to index1 from the selection.
setSelectionMode(number)()ListSelectionModel.SINGLE_SELECTION (0), SINGLE_INTERVAL_SELECTION (1) or MULTIPLE_INTERVAL_SELECTION (2, a new list's); any other ra…
getSelectionMode()numberThe selection mode.
setValueIsAdjusting(boolean)()Starts (true) or ends (false) one gesture of selection changes: its events say they are adjusting, and the end fires once more over eve…
getValueIsAdjusting()booleanWhether a gesture is in progress.
setFixedCellHeight(number)()Every cell this tall (-1: each row's renderer decides).
getFixedCellHeight()numberThe fixed cell height, or -1.
setFixedCellWidth(number)()Every cell this wide (-1: the widest row's renderer decides).
getFixedCellWidth()numberThe fixed cell width, or -1.
setLayoutOrientation(number)()JList.VERTICAL (0), VERTICAL_WRAP (1) or HORIZONTAL_WRAP (2); any other raises. The wrapping orientations lay out as VERTICAL in Be…
getLayoutOrientation()numberThe orientation.
setVisibleRowCount(number)()How many rows a scroll pane shows of it by default (8).
getVisibleRowCount()numberThe visible row count.
locationToIndex(Point)numberThe row closest to location (in the list's coordinates), or -1 when the model is empty; compare with getCellBounds to know whether the…
indexToLocation(number)Point?The origin of row index's cell, or nil outside the model.
getCellBounds(number, number)Rectangle?The bounds of the cells of rows index0 to index1 (their union), or nil when either row is outside the model.
ensureIndexIsVisible(number)()Scrolls the enclosing scroll pane so row index's cell shows.
getFirstVisibleIndex()numberThe first row showing, or -1.
getLastVisibleIndex()numberThe last row showing, or -1.
setCellRenderer(any)()Paints each cell with cellRenderer (a ListCellRenderer: a table with `getListCellRendererComponent(list, value, index, isSelected, cell…
getCellRenderer()ListCellRenderer?The renderer setCellRenderer was given, or nil for the default one.
addListSelectionListener(any)()Adds a ListSelectionListener (a table with valueChanged, or that function): it hears each selection change, the last added first; its e…
removeListSelectionListener(any)()Removes a ListSelectionListener, by identity.
getListSelectionListeners(){any}The ListSelectionListeners, in registration order.
getModel()anyThe model given, or JList()'s empty one.
getSelectedValue()anyThe model's element at the first selected row, or nil.
setModel(any)()Shows model and clears the selection; nil raises.
new(any)JList() -> JList: An empty list (its model getModel() answers, empty and read-only).
init(JList, any)()(JList) -> (): An empty list (its model getModel() answers, empty and read-only).
isInstance(any)booleanWhether obj is a JList object, a class(JList) subclass's included.

Fields

FieldTypeDescription
VERTICALnumberJList.VERTICAL: the vertical orientation, one column of rows (0).
VERTICAL_WRAPnumberJList.VERTICAL_WRAP (1): laid out as VERTICAL.
HORIZONTAL_WRAPnumberJList.HORIZONTAL_WRAP (2): laid out as VERTICAL.
superJComponentClassJComponent's class table: the base class.

Returned by

MethodReturnsDescription
JListClass.newJList() -> JList: An empty list (its model getModel() answers, empty and read-only).

Method details

setSelectedIndex

setSelectedIndex: (JList, number) -> ()

Selects that row alone; a row at or past the model's size, or -1, does nothing. Below -1 raises.

setSelectedIndices

setSelectedIndices: (JList, {number}) -> ()

Selects these rows (those at or past the model's size are ignored).

setSelectionInterval

setSelectionInterval: (JList, number, number) -> ()

Selects the rows index0 to index1 (only index1 in SINGLE_SELECTION).

setSelectionMode

setSelectionMode: (JList, number) -> ()

ListSelectionModel.SINGLE_SELECTION (0), SINGLE_INTERVAL_SELECTION (1) or MULTIPLE_INTERVAL_SELECTION (2, a new list's); any other raises.

setValueIsAdjusting

setValueIsAdjusting: (JList, boolean) -> ()

Starts (true) or ends (false) one gesture of selection changes: its events say they are adjusting, and the end fires once more over every row it changed.

setFixedCellWidth

setFixedCellWidth: (JList, number) -> ()

Every cell this wide (-1: the widest row's renderer decides).

setLayoutOrientation

setLayoutOrientation: (JList, number) -> ()

JList.VERTICAL (0), VERTICAL_WRAP (1) or HORIZONTAL_WRAP (2); any other raises. The wrapping orientations lay out as VERTICAL in Bento.

locationToIndex

locationToIndex: (JList, Point) -> number

The row closest to location (in the list's coordinates), or -1 when the model is empty; compare with getCellBounds to know whether the row holds it.

getCellBounds

getCellBounds: (JList, number, number) -> Rectangle?

The bounds of the cells of rows index0 to index1 (their union), or nil when either row is outside the model.

setCellRenderer

setCellRenderer: (JList, any) -> ()

Paints each cell with cellRenderer (a ListCellRenderer: a table with getListCellRendererComponent(list, value, index, isSelected, cellHasFocus), or that function), asked again when the list repaints or measures its cells, never per frame; nil is the default renderer (a label of the value's text).

addListSelectionListener

addListSelectionListener: (JList, any) -> ()

Adds a ListSelectionListener (a table with valueChanged, or that function): it hears each selection change, the last added first; its events' source is the list.

getModel

getModel: (JList) -> any

The model given, or JList()'s empty one.

setModel

setModel: (JList, any) -> ()

Shows model and clears the selection; nil raises.

new

new: (any) -> JList

() -> JList: An empty list (its model getModel() answers, empty and read-only).

(any) -> JList: A list showing dataModel: a DefaultListModel, or a plugin's model (an AbstractListModel subclass with getSize and getElementAt). nil is refused.

init

init: (JList, any) -> ()

(JList) -> (): An empty list (its model getModel() answers, empty and read-only).

(JList, any) -> (): A list showing dataModel: a DefaultListModel, or a plugin's model (an AbstractListModel subclass with getSize and getElementAt). nil is refused.

isInstance

isInstance: (any) -> boolean

Whether obj is a JList object, a class(JList) subclass's included.