public class JList extends JComponent implements Accessible, Scrollable
This class is a facade over three separate objects: ListModel, ListSelectionModel and
ListUI. The facade represents a unified "list"
concept, with independently replacable (possibly client-provided) models
for its contents and its current selection. In addition, each element in
the list is rendered via a strategy class ListCellRenderer.
Lists have many properties, some of which are stored in this class while others are delegated to the list's model or selection. The following properties are available:
| Property | Stored in | Bound? |
|---|---|---|
| accessibleContext | list | no |
| anchorSelectionIndex | selection | no |
| cellRenderer | list | yes |
| dragEnabled | list | no |
| firstVisibleIndex | list | no |
| fixedCellHeight | list | yes |
| fixedCellWidth | list | yes |
| lastVisibleIndex | list | no |
| layoutOrientation | list | yes |
| leadSelectionIndex | selection | no |
| maxSelectionIndex | selection | no |
| minSelectionIndex | selection | no |
| model | list | yes |
| opaque | list | no |
| preferredScrollableViewportSize | list | no |
| prototypeCellValue | list | yes |
| scrollableTracksViewportHeight | list | no |
| scrollableTracksViewportWidth | list | no |
| selectedIndex | selection | no |
| selectedIndices | selection | no |
| selectedValue | model | no |
| selectedValues | model | no |
| selectionBackground | list | yes |
| selectionEmpty | selection | no |
| selectionForeground | list | yes |
| selectionMode | selection | no |
| selectionModel | list | yes |
| UI | list | yes |
| UIClassID | list | no |
| valueIsAdjusting | list | no |
| visibleRowCount | list | no |
| Modifier and Type | Class and Description |
|---|---|
protected class |
JList.AccessibleJList
Provides accessibility support for
JList. |
JComponent.AccessibleJComponentContainer.AccessibleAWTContainerComponent.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy| Modifier and Type | Field and Description |
|---|---|
static int |
HORIZONTAL_WRAP
Constant value used in "layoutOrientation" property.
|
static int |
VERTICAL
Constant value used in "layoutOrientation" property.
|
static int |
VERTICAL_WRAP
Constant value used in "layoutOrientation" property.
|
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOWBOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH| Constructor and Description |
|---|
JList()
Creates a new
JList object. |
JList(ListModel model)
Creates a new
JList object. |
JList(Object[] items)
Creates a new
JList object. |
JList(Vector<?> items)
Creates a new
JList object. |
| Modifier and Type | Method and Description |
|---|---|
void |
addListSelectionListener(ListSelectionListener listener)
Adds a
ListSelectionListener to the listener list for this
list. |
void |
addSelectionInterval(int anchor,
int lead)
Adds the specified interval to the current selection.
|
void |
clearSelection()
Clears the current selection.
|
protected ListSelectionModel |
createSelectionModel()
Creates the default
ListSelectionModel. |
void |
ensureIndexIsVisible(int i)
Scrolls this list to make the specified cell visible.
|
protected void |
fireSelectionValueChanged(int firstIndex,
int lastIndex,
boolean isAdjusting)
Fire a
ListSelectionEvent to all the registered
ListSelectionListeners. |
AccessibleContext |
getAccessibleContext()
Get the value of the accessibleContext property for this component.
|
int |
getAnchorSelectionIndex()
Returns the index of the anchor item in the current selection, or
-1 if there is no anchor item. |
Rectangle |
getCellBounds(int index0,
int index1)
Returns the bounds of the rectangle that encloses both list cells
with index0 and index1.
|
ListCellRenderer |
getCellRenderer()
Gets the value of the
cellRenderer property. |
boolean |
getDragEnabled()
Return the value of the
dragEnabled property. |
int |
getFirstVisibleIndex()
Returns the list index of the upper left or upper right corner of the
visible rectangle of this list, depending on the
Component.getComponentOrientation() property. |
int |
getFixedCellHeight()
Gets the value of the
fixedCellHeight property. |
int |
getFixedCellWidth()
Gets the value of the
fixedCellWidth property. |
int |
getLastVisibleIndex()
Returns the list index of the lower right or lower left corner of the
visible rectangle of this list, depending on the
Component.getComponentOrientation() property. |
int |
getLayoutOrientation()
|
int |
getLeadSelectionIndex()
Returns the index of the lead item in the current selection, or
-1 if there is no lead item. |
ListSelectionListener[] |
getListSelectionListeners()
Returns an array of all ListSelectionListeners subscribed to this
list.
|
int |
getMaxSelectionIndex()
Returns the highest item index in the current selection, or
-1 if there is no selection. |
int |
getMinSelectionIndex()
Returns the lowest item index in the current selection, or
-1
if there is no selection. |
ListModel |
getModel()
Gets the value of the
model property. |
int |
getNextMatch(String prefix,
int startIndex,
Position.Bias direction)
Returns the index of the next list element (beginning at
startIndex and moving in the specified direction through the
list, looping around if necessary) that starts with prefix
(ignoring case). |
Dimension |
getPreferredScrollableViewportSize()
Returns a size indicating how much space this list would like to
consume, when contained in a scrollable viewport.
|
Object |
getPrototypeCellValue()
Returns the current value of the
prototypeCellValue
property. |
int |
getScrollableBlockIncrement(Rectangle visibleRect,
int orientation,
int direction)
Return the number of pixels the list must scroll in order to move a
"block" of the list into the provided visible rectangle.
|
boolean |
getScrollableTracksViewportHeight()
Gets the value of the scrollableTracksViewportWidth property.
|
boolean |
getScrollableTracksViewportWidth()
Gets the value of the
scrollableTracksViewportWidth property. |
int |
getScrollableUnitIncrement(Rectangle visibleRect,
int orientation,
int direction)
Return the number of pixels the list must scroll in order to move a
"unit" of the list into the provided visible rectangle.
|
int |
getSelectedIndex()
Returns the minimum index of an element in the list which is currently
selected.
|
int[] |
getSelectedIndices()
Returns the indices of values in the
model property which are
selected. |
Object |
getSelectedValue()
Returns the first value in the list's
model property which is
selected, according to the list's selectionModel property. |
Object[] |
getSelectedValues()
Returns all the values in the list's
model property which are
selected, according to the list's selectionModel property. |
Color |
getSelectionBackground()
Gets the value of the
selectionBackground property. |
Color |
getSelectionForeground()
Gets the value of the
selectionForeground property. |
int |
getSelectionMode()
Returns the selection mode for the list (one of:
ListSelectionModel.SINGLE_SELECTION,
ListSelectionModel.SINGLE_INTERVAL_SELECTION and
ListSelectionModel.MULTIPLE_INTERVAL_SELECTION). |
ListSelectionModel |
getSelectionModel()
Returns the selection model for the
JList component. |
ListUI |
getUI()
Gets the value of the UI property.
|
String |
getUIClassID()
Return the class identifier for the list's UI property.
|
boolean |
getValueIsAdjusting()
Returns the
valueIsAdjusting flag from the list's selection
model. |
int |
getVisibleRowCount()
Gets the value of the
visibleRowCount property. |
Point |
indexToLocation(int index)
Returns location of the cell located at the specified index in the list.
|
boolean |
isSelectedIndex(int a)
Indicates whether the list element at a given index value is
currently selected.
|
boolean |
isSelectionEmpty()
Returns
true if the model's selection is empty, otherwise
false. |
int |
locationToIndex(Point location)
Returns index of the cell to which specified location is closest to.
|
protected String |
paramString()
Returns a string describing the attributes for the
JList
component, for use in debugging. |
void |
removeListSelectionListener(ListSelectionListener listener)
Removes a
ListSelectionListener from the listener list for
this list. |
void |
removeSelectionInterval(int index0,
int index1)
Removes the specified interval from the current selection.
|
void |
setCellRenderer(ListCellRenderer renderer)
Sets the value of the
getCellRenderer() property. |
void |
setDragEnabled(boolean enabled)
Set the
dragEnabled property. |
void |
setFixedCellHeight(int h)
Sets the value of the
fixedCellHeight property. |
void |
setFixedCellWidth(int w)
Sets the value of the
fixedCellWidth property. |
void |
setLayoutOrientation(int orientation)
Sets the layout orientation (this is a bound property with the name
'layoutOrientation').
|
void |
setListData(Object[] listData)
Sets the
model property of the list to a new anonymous
AbstractListModel subclass which accesses the provided Object
array directly. |
void |
setListData(Vector<?> listData)
Sets the
model property of the list to a new anonymous AbstractListModel subclass which accesses the provided vector
directly. |
void |
setModel(ListModel model)
Sets the value of the
model property. |
void |
setPrototypeCellValue(Object obj)
Set the
prototypeCellValue property. |
void |
setSelectedIndex(int a)
Adds the interval
[a,a] to the set of selections managed
by this list's selectionModel property. |
void |
setSelectedIndices(int[] a)
|
void |
setSelectedValue(Object obj,
boolean scroll)
Sets the selection to cover only the specified value, if it
exists in the model.
|
void |
setSelectionBackground(Color c)
Sets the value of the
selectionBackground property. |
void |
setSelectionForeground(Color c)
Sets the value of the
selectionForeground property. |
void |
setSelectionInterval(int anchor,
int lead)
Sets the current selection to the items in the specified range (inclusive).
|
void |
setSelectionMode(int a)
Sets the list's "selectionMode" property, which simply mirrors the
same property on the list's
selectionModel property. |
void |
setSelectionModel(ListSelectionModel model)
Sets the value of the
selectionModel property. |
void |
setUI(ListUI ui)
Sets the value of the UI property.
|
void |
setValueIsAdjusting(boolean isAdjusting)
Sets the
valueIsAdjusting flag in the list's selection
model. |
void |
setVisibleRowCount(int vc)
Sets the value of the
visibleRowCount property. |
void |
updateUI()
Calls
setUI(javax.swing.plaf.ListUI) with the ListUI subclass
returned from calling UIManager.getUI(javax.swing.JComponent). |
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setNextFocusableComponent, setOpaque, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, updateadd, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTreeaction, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCyclepublic static final int VERTICAL
public static final int VERTICAL_WRAP
public static final int HORIZONTAL_WRAP
public JList()
JList object.public JList(Object[] items)
JList object.items - the initial list items.public JList(Vector<?> items)
JList object.items - the initial list items.public JList(ListModel model)
JList object.model - a model containing the list items (null not
permitted).IllegalArgumentException - if model is
null.protected void fireSelectionValueChanged(int firstIndex, int lastIndex, boolean isAdjusting)
ListSelectionEvent to all the registered
ListSelectionListeners.firstIndex - the lowest index covering the selection change.lastIndex - the highest index covering the selection change.isAdjusting - a flag indicating if this event is one in a series
of events updating the selection.protected ListSelectionModel createSelectionModel()
ListSelectionModel.ListSelectionModelpublic int getFixedCellHeight()
fixedCellHeight property. This property
may be -1 to indicate that no cell height has been
set. This property is also set implicitly when the
prototypeCellValue property is set.fixedCellHeight,
setFixedCellHeight(int),
setPrototypeCellValue(java.lang.Object)public void setFixedCellHeight(int h)
fixedCellHeight property. This property
may be -1 to indicate that no cell height has been
set. This property is also set implicitly when the prototypeCellValue property is set, but setting it explicitly
overrides the height computed from prototypeCellValue.h - the height.getFixedCellHeight(),
getPrototypeCellValue()public int getFixedCellWidth()
fixedCellWidth property. This property
may be -1 to indicate that no cell width has been
set. This property is also set implicitly when the prototypeCellValue property is set.setFixedCellWidth(int),
setPrototypeCellValue(java.lang.Object)public void setFixedCellWidth(int w)
fixedCellWidth property. This property
may be -1 to indicate that no cell width has been
set. This property is also set implicitly when the prototypeCellValue property is set, but setting it explicitly
overrides the width computed from prototypeCellValue.w - the width.getFixedCellHeight(),
getPrototypeCellValue()public int getVisibleRowCount()
visibleRowCount property. The default
value is 8.setVisibleRowCount(int)public void setVisibleRowCount(int vc)
visibleRowCount property.vc - The new property valuegetVisibleRowCount()public void addListSelectionListener(ListSelectionListener listener)
ListSelectionListener to the listener list for this
list. The listener will be called back with a ListSelectionEvent any time the list's selectionModel
property changes. The source of such events will be the JList,
not the selection model.listener - The new listener to addpublic void removeListSelectionListener(ListSelectionListener listener)
ListSelectionListener from the listener list for
this list. The listener will no longer be called when the list's
selectionModel changes.listener - The listener to removepublic ListSelectionListener[] getListSelectionListeners()
public int getSelectionMode()
ListSelectionModel.SINGLE_SELECTION,
ListSelectionModel.SINGLE_INTERVAL_SELECTION and
ListSelectionModel.MULTIPLE_INTERVAL_SELECTION).setSelectionMode(int)public void setSelectionMode(int a)
selectionModel property. This
property should be one of the integer constants
SINGLE_SELECTION, SINGLE_INTERVAL_SELECTION,
or MULTIPLE_INTERVAL_SELECTION from the ListSelectionModel interface.a - The new selection modepublic void setSelectedIndex(int a)
[a,a] to the set of selections managed
by this list's selectionModel property. Depending on the
selection mode, this may cause existing selections to become invalid,
or may simply expand the set of selections.a - A number in the half-open range [0, x) where
x = getModel.getSize(), indicating the index of an
element in the list to select. When < 0 the selection is cleared.setSelectionMode(int),
selectionModelpublic void setSelectedIndices(int[] a)
a - an array of selected indices (null not permitted).NullPointerException - if a is null.setSelectionMode(int),
selectionModelpublic int getSelectedIndex()
[0, x) where
x = getModel.getSize(), indicating the minimum index of
an element in the list for which the element is selected, or
-1 if no elements are selectedpublic boolean isSelectionEmpty()
true if the model's selection is empty, otherwise
false.ListSelectionModel.isSelectionEmpty()public int getFirstVisibleIndex()
Component.getComponentOrientation() property.-1
if none is visible.public int locationToIndex(Point location)
-1 is returned.location - for which to look for in the listpublic Point indexToLocation(int index)
index - of the cell for which location will be determinedpublic int getLastVisibleIndex()
Component.getComponentOrientation() property.-1
if none is visible.public int[] getSelectedIndices()
model property which are
selected.getSelectedValues() propertypublic boolean isSelectedIndex(int a)
a - The index to checktrue if a is the index of a selected
list elementpublic Object getSelectedValue()
model property which is
selected, according to the list's selectionModel property.
This is equivalent to calling
getModel()getElementAt(getSelectedIndex()), with a check
for the special index value of -1 which returns null
null.null if no element
is selected.getSelectedValues()public Object[] getSelectedValues()
model property which are
selected, according to the list's selectionModel property.setSelectedValue(java.lang.Object, boolean)public Color getSelectionBackground()
selectionBackground property.public void setSelectionBackground(Color c)
selectionBackground property.c - The new value of the propertypublic Color getSelectionForeground()
selectionForeground property.public void setSelectionForeground(Color c)
selectionForeground property.c - The new value of the propertypublic void setSelectedValue(Object obj, boolean scroll)
obj - The object to selectscroll - Whether to scroll the list to make the newly selected
value visibleensureIndexIsVisible(int)public void ensureIndexIsVisible(int i)
i - The list index to make visibleJComponent.scrollRectToVisible(java.awt.Rectangle)public void setListData(Object[] listData)
model property of the list to a new anonymous
AbstractListModel subclass which accesses the provided Object
array directly.listData - The object array to build a new list model onsetModel(javax.swing.ListModel)public void setListData(Vector<?> listData)
model property of the list to a new anonymous AbstractListModel subclass which accesses the provided vector
directly.listData - The object array to build a new list model onsetModel(javax.swing.ListModel)public ListCellRenderer getCellRenderer()
cellRenderer property.public void setCellRenderer(ListCellRenderer renderer)
getCellRenderer() property.renderer - The new property valuepublic ListModel getModel()
model property.public void setModel(ListModel model)
model property. The list's listListener is unsubscribed from the existing model, if it exists,
and re-subscribed to the new model.model - the new model (null not permitted).IllegalArgumentException - if model is
null.public ListSelectionModel getSelectionModel()
JList component. Note that
this class contains a range of convenience methods for configuring the
selection model:public void setSelectionModel(ListSelectionModel model)
selectionModel property. The list's
listListener is unsubscribed from the existing selection
model, if it exists, and re-subscribed to the new selection model.model - The new property valuepublic void setUI(ListUI ui)
ui - The new property valuepublic void updateUI()
setUI(javax.swing.plaf.ListUI) with the ListUI subclass
returned from calling UIManager.getUI(javax.swing.JComponent).updateUI in class JComponentpublic String getUIClassID()
"ListUI", and map to an
appropriate UI class in the UIManager.getUIClassID in class JComponentJComponent.setUI(javax.swing.plaf.ComponentUI),
JComponent.updateUI()public Object getPrototypeCellValue()
prototypeCellValue
property. This property holds a reference to a "prototype" data value
-- typically a String -- which is used to calculate the fixedCellWidth and fixedCellHeight properties, using the
cellRenderer property to acquire a component to render the
prototype.setPrototypeCellValue(java.lang.Object)public void setPrototypeCellValue(Object obj)
Set the prototypeCellValue property. This property holds a
reference to a "prototype" data value -- typically a String -- which
is used to calculate the fixedCellWidth and fixedCellHeight properties, using the cellRenderer property
to acquire a component to render the prototype.
It is important that you not set this value to a component. It has to be a data value such as the objects you would find in the list's model. Setting it to a component will have undefined (and undesirable) affects.
obj - The new prototype cell valuegetPrototypeCellValue()public AccessibleContext getAccessibleContext()
JComponentgetAccessibleContext in interface AccessiblegetAccessibleContext in class JComponentpublic Dimension getPreferredScrollableViewportSize()
Scrollable interface, which interacts with ScrollPaneLayout and JViewport to define scrollable objects.getPreferredScrollableViewportSize in interface Scrollablepublic int getScrollableUnitIncrement(Rectangle visibleRect, int orientation, int direction)
Return the number of pixels the list must scroll in order to move a "unit" of the list into the provided visible rectangle. When the provided direction is positive, the call describes a "downwards" scroll, which will be exposing a cell at a greater index in the list than those elements currently showing. Then the provided direction is negative, the call describes an "upwards" scroll, which will be exposing a cell at a lesser index in the list than those elements currently showing.
If the provided orientation is HORIZONTAL, the above
comments refer to "rightwards" for positive direction, and "leftwards"
for negative.
getScrollableUnitIncrement in interface ScrollablevisibleRect - The rectangle to scroll an element intoorientation - One of the numeric consants VERTICAL
or HORIZONTALdirection - An integer indicating the scroll direction: positive means
forwards (down, right), negative means backwards (up, left)public int getScrollableBlockIncrement(Rectangle visibleRect, int orientation, int direction)
Return the number of pixels the list must scroll in order to move a "block" of the list into the provided visible rectangle. When the provided direction is positive, the call describes a "downwards" scroll, which will be exposing a cell at a greater index in the list than those elements currently showing. Then the provided direction is negative, the call describes an "upwards" scroll, which will be exposing a cell at a lesser index in the list than those elements currently showing.
If the provided orientation is HORIZONTAL, the above
comments refer to "rightwards" for positive direction, and "leftwards"
for negative.
getScrollableBlockIncrement in interface ScrollablevisibleRect - The rectangle to scroll an element intoorientation - One of the numeric consants VERTICAL
or HORIZONTALdirection - An integer indicating the scroll direction: positive means
forwards (down, right), negative means backwards (up, left)public boolean getScrollableTracksViewportWidth()
scrollableTracksViewportWidth property.getScrollableTracksViewportWidth in interface Scrollabletrue if the viewport is larger (horizontally)
than the list and the list should be expanded to fit the viewport;
false if the viewport is smaller than the list and the
list should scroll (horizontally) within the viewportpublic boolean getScrollableTracksViewportHeight()
getScrollableTracksViewportHeight in interface Scrollabletrue if the viewport is larger (vertically)
than the list and the list should be expanded to fit the viewport;
false if the viewport is smaller than the list and the
list should scroll (vertically) within the viewportpublic int getAnchorSelectionIndex()
-1 if there is no anchor item.public int getLeadSelectionIndex()
-1 if there is no lead item.public int getMinSelectionIndex()
-1
if there is no selection.getMaxSelectionIndex()public int getMaxSelectionIndex()
-1 if there is no selection.getMinSelectionIndex()public void clearSelection()
public void setSelectionInterval(int anchor, int lead)
anchor can be less than, equal to, or greater than
lead.anchor - the index of the anchor item.lead - the index of the anchor item.public void addSelectionInterval(int anchor, int lead)
anchor can be less than, equal to, or greater than
lead.anchor - the index of the anchor item.lead - the index of the lead item.public void removeSelectionInterval(int index0, int index1)
index0 can be less than, equal to, or greater than
index1.index0 - an index for one end of the range.index1 - an index for the other end of the range.public boolean getValueIsAdjusting()
valueIsAdjusting flag from the list's selection
model.public void setValueIsAdjusting(boolean isAdjusting)
valueIsAdjusting flag in the list's selection
model.isAdjusting - the new valuepublic boolean getDragEnabled()
dragEnabled property.public void setDragEnabled(boolean enabled)
dragEnabled property.enabled - new valuepublic int getLayoutOrientation()
VERTICAL,
VERTICAL_WRAP and HORIZONTAL_WRAP. The default value
is VERTICAL.setLayoutOrientation(int)public void setLayoutOrientation(int orientation)
VERTICAL,
VERTICAL_WRAP and HORIZONTAL_WRAP.orientation - the orientation.IllegalArgumentException - if orientation is not one
of the specified values.getLayoutOrientation()public Rectangle getCellBounds(int index0, int index1)
index0 - the index of the first cellindex1 - the index of the second cellnull if one of the indices is
not validpublic int getNextMatch(String prefix, int startIndex, Position.Bias direction)
startIndex and moving in the specified direction through the
list, looping around if necessary) that starts with prefix
(ignoring case).prefix - the prefix to search for in the cell valuesstartIndex - the index where to start searching fromdirection - the search direction, either Position.Bias#Forward
or Position.Bias#Backward (null is interpreted
as Position.Bias#Backward.IllegalArgumentException - if prefix is null or
startIndex is not validprotected String paramString()
JList
component, for use in debugging. The return value is guaranteed to be
non-null, but the format of the string may vary between
implementations.paramString in class JComponentJList.