Java javax.swing JList fields, constructors, methods, implement or subclass

Example usage for Java javax.swing JList fields, constructors, methods, implement or subclass

Introduction

In this page you can find the methods, fields and constructors for javax.swing JList.

The text is from its open source code.

Subclass

javax.swing.JList has subclasses.
Click this link to see all its subclasses.

Field

intVERTICAL
Indicates a vertical layout of cells, in a single column; the default layout.
intVERTICAL_WRAP
Indicates a "newspaper style" layout with cells flowing vertically then horizontally.
intHORIZONTAL_WRAP
Indicates a "newspaper style" layout with cells flowing horizontally then vertically.

Constructor

JList()
Constructs a JList with an empty, read-only, model.
JList(ListModel dataModel)
Constructs a JList that displays elements from the specified, non-null , model.
JList(final E[] listData)
Constructs a JList that displays the elements in the specified array.
JList(final Vector listData)
Constructs a JList that displays the elements in the specified Vector.

Method

voidaddFocusListener(FocusListener l)
Adds the specified focus listener to receive focus events from this component when this component gains input focus.
voidaddKeyListener(KeyListener l)
Adds the specified key listener to receive key events from this component.
voidaddListSelectionListener(ListSelectionListener listener)
Adds a listener to the list, to be notified each time a change to the selection occurs; the preferred way of listening for selection state changes.
voidaddMouseListener(MouseListener l)
Adds the specified mouse listener to receive mouse events from this component.
voidaddSelectionInterval(int anchor, int lead)
Sets the selection to be the union of the specified interval with current selection.
voidclearSelection()
Clears the selection; after calling this method, isSelectionEmpty will return true .
voidensureIndexIsVisible(int index)
Scrolls the list within an enclosing viewport to make the specified cell completely visible.
booleanequals(Object obj)
Indicates whether some other object is "equal to" this one.
ActionMapgetActionMap()
Returns the ActionMap used to determine what Action to fire for particular KeyStroke binding.
intgetAnchorSelectionIndex()
Returns the anchor selection index.
ColorgetBackground()
Gets the background color of this component.
RectanglegetCellBounds(int index0, int index1)
Returns the bounding rectangle, in the list's coordinate system, for the range of cells specified by the two indices.
ListCellRenderergetCellRenderer()
Returns the object responsible for painting list items.
ObjectgetClientProperty(Object key)
Returns the value of the property with the specified key.
booleangetDragEnabled()
Returns whether or not automatic drag handling is enabled.
DropLocationgetDropLocation()
Returns the location that this component should visually indicate as the drop location during a DnD operation over the component, or null if no location is to currently be shown.
intgetFirstVisibleIndex()
Returns the smallest list index that is currently visible.
intgetFixedCellHeight()
Returns the value of the fixedCellHeight property.
intgetFixedCellWidth()
Returns the value of the fixedCellWidth property.
FontgetFont()
Gets the font of this component.
ColorgetForeground()
Gets the foreground color of this component.
InputMapgetInputMap(int condition)
Returns the InputMap that is used during condition.
intgetLastVisibleIndex()
Returns the largest list index that is currently visible.
intgetLayoutOrientation()
Returns the layout orientation property for the list: VERTICAL if the layout is a single column of cells, VERTICAL_WRAP if the layout is "newspaper style" with the content flowing vertically then horizontally, or HORIZONTAL_WRAP if the layout is "newspaper style" with the content flowing horizontally then vertically.
intgetLeadSelectionIndex()
Returns the lead selection index.
ListSelectionListener[]getListSelectionListeners()
Returns an array of all the ListSelectionListener s added to this JList by way of addListSelectionListener .
intgetMaxSelectionIndex()
Returns the largest selected cell index, or -1 if the selection is empty.
intgetMinSelectionIndex()
Returns the smallest selected cell index, or -1 if the selection is empty.
ListModelgetModel()
Returns the data model that holds the list of items displayed by the JList component.
intgetNextMatch(String prefix, int startIndex, Position.Bias bias)
Returns the next list element whose toString value starts with the given prefix.
DimensiongetPreferredScrollableViewportSize()
Computes the size of viewport needed to display visibleRowCount rows.
DimensiongetPreferredSize()
If the preferredSize has been set to a non-null value just returns it.
EgetPrototypeCellValue()
Returns the "prototypical" cell value -- a value used to calculate a fixed width and height for cells.
intgetSelectedIndex()
Returns the smallest selected cell index; the selection when only a single item is selected in the list.
int[]getSelectedIndices()
Returns an array of all of the selected indices, in increasing order.
EgetSelectedValue()
Returns the value for the smallest selected cell index; the selected value when only a single item is selected in the list.
Object[]getSelectedValues()
Returns an array of all the selected values, in increasing order based on their indices in the list.
ListgetSelectedValuesList()
Returns a list of all the selected items, in increasing order based on their indices in the list.
ColorgetSelectionBackground()
Returns the color used to draw the background of selected items.
ColorgetSelectionForeground()
Returns the color used to draw the foreground of selected items.
intgetSelectionMode()
Returns the current selection mode for the list.
ListSelectionModelgetSelectionModel()
Returns the current selection model.
intgetVisibleRowCount()
Returns the value of the visibleRowCount property.
PointindexToLocation(int index)
Returns the origin of the specified item in the list's coordinate system.
booleanisEnabled()
Determines whether this component is enabled.
booleanisSelectedIndex(int index)
Returns true if the specified index is selected, else false .
booleanisSelectionEmpty()
Returns true if nothing is selected, else false .
booleanisShowing()
Determines whether this component is showing on screen.
booleanisVisible()
Determines whether this component should be visible when its parent is visible.
intlocationToIndex(Point location)
Returns the cell index closest to the given location in the list's coordinate system.
voidputClientProperty(Object key, Object value)
Adds an arbitrary key/value "client property" to this component.
voidremoveListSelectionListener(ListSelectionListener listener)
Removes a selection listener from the list.
voidremoveSelectionInterval(int index0, int index1)
Sets the selection to be the set difference of the specified interval and the current selection.
voidrepaint(Rectangle r)
Adds the specified region to the dirty region list if the component is showing.
voidrepaint()
Repaints this component.
voidrequestFocus()
Requests that this Component gets the input focus.
booleanrequestFocusInWindow()
Requests that this Component gets the input focus.
voidrevalidate()
Supports deferred automatic layout.
voidscrollRectToVisible(Rectangle aRect)
Forwards the scrollRectToVisible() message to the JComponent's parent.
voidsetBackground(Color bg)
Sets the background color of this component.
voidsetBorder(Border border)
Sets the border of this component.
voidsetBounds(int x, int y, int width, int height)
Moves and resizes this component.
voidsetCellRenderer(ListCellRenderer cellRenderer)
Sets the delegate that is used to paint each cell in the list.
voidsetComponentPopupMenu(JPopupMenu popup)
Sets the JPopupMenu for this JComponent.
voidsetDragEnabled(boolean b)
Turns on or off automatic drag handling.
voidsetDropMode(DropMode dropMode)
Sets the drop mode for this component.
voidsetEnabled(boolean enabled)
Sets whether or not this component is enabled.
voidsetFixedCellHeight(int height)
Sets a fixed value to be used for the height of every cell in the list.
voidsetFixedCellWidth(int width)
Sets a fixed value to be used for the width of every cell in the list.
voidsetFocusable(boolean focusable)
Sets the focusable state of this Component to the specified value.
voidsetLayoutOrientation(int layoutOrientation)
Defines the way list cells are layed out.
voidsetListData(final E[] listData)
Constructs a read-only ListModel from an array of items, and calls setModel with this model.
voidsetListData(final Vector listData)
Constructs a read-only ListModel from a Vector and calls setModel with this model.
voidsetMinimumSize(Dimension minimumSize)
Sets the minimum size of this component to a constant value.
voidsetModel(ListModel model)
Sets the model that represents the contents or "value" of the list, notifies property change listeners, and then clears the list's selection.
voidsetName(String name)
Sets the name of the component to the specified string.
voidsetOpaque(boolean isOpaque)
If true the component paints every pixel within its bounds.
voidsetPreferredSize(Dimension preferredSize)
Sets the preferred size of this component.
voidsetPrototypeCellValue(E prototypeCellValue)
Sets the prototypeCellValue property, and then (if the new value is non-null ), computes the fixedCellWidth and fixedCellHeight properties by requesting the cell renderer component for the given value (and index 0) from the cell renderer, and using that component's preferred size.
voidsetSelectedIndex(int index)
Selects a single cell.
voidsetSelectedIndices(int[] indices)
Changes the selection to be the set of indices specified by the given array.
voidsetSelectedValue(Object anObject, boolean shouldScroll)
Selects the specified object from the list.
voidsetSelectionBackground(Color selectionBackground)
Sets the color used to draw the background of selected items, which cell renderers can use fill selected cells.
voidsetSelectionForeground(Color selectionForeground)
Sets the color used to draw the foreground of selected items, which cell renderers can use to render text and graphics.
voidsetSelectionInterval(int anchor, int lead)
Selects the specified interval.
voidsetSelectionMode(int selectionMode)
Sets the selection mode for the list.
voidsetSelectionModel(ListSelectionModel selectionModel)
Sets the selectionModel for the list to a non-null ListSelectionModel implementation.
voidsetToolTipText(String text)
Registers the text to display in a tool tip.
voidsetTransferHandler(TransferHandler newHandler)
Sets the TransferHandler , which provides support for transfer of data into and out of this component via cut/copy/paste and drag and drop.
voidsetUI(ListUI ui)
Sets the ListUI , the look and feel object that renders this component.
voidsetValueIsAdjusting(boolean b)
Sets the selection model's valueIsAdjusting property.
voidsetVisible(boolean aFlag)
Makes the component visible or invisible.
voidsetVisibleRowCount(int visibleRowCount)
Sets the visibleRowCount property, which has different meanings depending on the layout orientation: For a VERTICAL layout orientation, this sets the preferred number of rows to display without requiring scrolling; for other orientations, it affects the wrapping of cells.
voidupdateUI()
Resets the ListUI property by setting it to the value provided by the current look and feel.