APIdia Launch Partner
Top Description Inners Fields Constructors Methods
javax.swing.plaf.basic

public Class BasicListUI

extends ListUI
Class Inheritance
Known Direct Subclasses
javax.swing.plaf.synth.SynthListUI
Imports
sun.swing.DefaultLookup, .UIAction, .SwingUtilities2, javax.swing.*, javax.swing.event.*, javax.swing.plaf.*, javax.swing.text.Position, java.awt.*, java.awt.event.*, java.awt.datatransfer.Transferable, java.awt.geom.Point2D, java.beans.PropertyChangeListener, .PropertyChangeEvent, javax.swing.plaf.basic.DragRecognitionSupport.BeforeDrag

An extensible implementation of ListUI.

BasicListUI instances cannot be shared between multiple lists.

Authors
Hans Muller, Philip Milne, Shannon Hickey (drag and drop)

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
public class
BasicListUI.FocusHandler

This class should be treated as a "protected" inner class.

private class
public class
BasicListUI.ListDataHandler

The ListDataListener that's added to the JLists model at installUI time, and whenever the JList.model property changes.

public class
BasicListUI.ListSelectionHandler

The ListSelectionListener that's added to the JLists selection model at installUI time, and whenever the JList.selectionModel property changes.

pack-priv static class
public class
BasicListUI.MouseInputHandler

Mouse input, and focus handling for JList.

public class
BasicListUI.PropertyChangeHandler

The PropertyChangeListener that's added to the JList at installUI time.

Field Summary

Modifier and TypeField and Description
private static final StringBuilder
protected int
cellHeight

The height of cell.

protected int[]
cellHeights

The array of cells' height

protected static final int
cellRendererChanged

The bit relates to cell renderer changed property.

protected int
cellWidth

The width of cell.

private static final int
CHANGE_LEAD

Used by IncrementLeadSelectionAction.

private static final int
CHANGE_SELECTION

Used by IncrementLeadSelectionAction.

private int
columnCount

Number of columns to create.

private static final int
private static final TransferHandler
private static final int
private static final int
EXTEND_SELECTION

Used by IncrementLeadSelectionAction.

protected static final int
fixedCellHeightChanged

The bit relates to fixed cell height changed property.

protected static final int
fixedCellWidthChanged

The bit relates to fixed cell width changed property.

protected FocusListener
focusListener

FocusListener that attached to JList.

protected static final int
fontChanged

The bit relates to font changed property.

private BasicListUI.Handler
private static final int
private boolean
isFileList

Local cache of JList's client property "List.isFileList"

private boolean
isLeftToRight

Local cache of JList's component orientation property

private int
layoutOrientation

The layout orientation of the list.

private static final int
protected JList<Object>
list

The instance of JList.

protected ListDataListener
listDataListener

ListDataListener that attached to JList.

private int
listHeight

Height of the list.

protected ListSelectionListener
listSelectionListener

ListSelectionListener that attached to JList.

private int
listWidth

Width of the list.

protected static final int
modelChanged

The bit relates to model changed property.

protected MouseInputListener
mouseInputListener

MouseInputListener that attached to JList.

private int
preferredHeight

Preferred height to make the list, this is only used if the the list is laid out horizontally.

protected PropertyChangeListener
propertyChangeListener

PropertyChangeListener that attached to JList.

protected static final int
prototypeCellValueChanged

The bit relates to prototype cell value changed property.

protected CellRendererPane
rendererPane

The instance of CellRendererPane.

private int
rowsPerColumn

Number of rows per column.

protected static final int
selectionModelChanged

The bit relates to selection model changed property.

private long
timeFactor

The time factor to treat the series of typed alphanumeric key as prefix for first letter navigation.

protected int
updateLayoutStateNeeded

The value represents changes to JList model.

private static final int

Constructor Summary

AccessConstructor and Description
public
BasicListUI()

Constructs a BasicListUI.

Method Summary

Modifier and TypeMethod and Description
private static int
adjustIndex(int index, JList<?> list)

private int
convertLocationToColumn(int x, int y)

Returns the closest column to the passed in location.

private int
convertLocationToModel(int x, int y)

Returns the closest location to the model index of the passed in location.

private int
convertLocationToRow(int x, int y0, boolean
If true and the location doesn't exactly match a particular location, this will return the closest row.
closest
)

Returns the row at location x/y.

private int
convertLocationToRowInColumn(int y, int column)

Returns the closest row that starts at the specified y-location in the passed in column.

private int
convertModelToColumn(int index)

Returns the column that the model index index will be displayed in.

private int
convertModelToRow(int index)

Returns the row that the model index index will be displayed in..

protected int

Returns:

the Y coordinate of the origin of row, or -1
convertRowToY
(int
a row
row
)

Return the JList relative Y coordinate of the origin of the specified row or -1 if row isn't valid.

protected int

Returns:

the row that contains y0, or -1
convertYToRow
(int
a relative Y coordinate
y0
)

Convert the JList relative coordinate to the row that contains it, based on the current layout.

protected FocusListener

Returns:

an instance of FocusListener
createFocusListener
()

Returns an instance of FocusListener.

protected ListDataListener

Returns:

an instance of ListDataListener
createListDataListener
()

Creates an instance of ListDataListener that's added to the JLists by model as needed.

protected ListSelectionListener

Returns:

an instance of ListSelectionHandler
createListSelectionListener
()

Creates an instance of ListSelectionHandler that's added to the JLists by selectionModel as needed.

protected MouseInputListener

Returns:

an instance of MouseInputListener
createMouseInputListener
()

Creates a delegate that implements MouseInputListener.

protected PropertyChangeListener

Returns:

an instance of PropertyChangeHandler
createPropertyChangeListener
()

Creates an instance of PropertyChangeHandler that's added to the JList by installUI().

public static ComponentUI

Returns:

a new ListUI implementation for the Windows look and feel.
createUI
(JComponent
a component
list
)

Hides javax.swing.plaf.ComponentUI.createUI.

Returns a new instance of BasicListUI.

public int
getBaseline(JComponent c, int width, int height)

Overrides javax.swing.plaf.ComponentUI.getBaseline.

Returns the baseline.

public Component.BaselineResizeBehavior
getBaselineResizeBehavior(JComponent c)

Overrides javax.swing.plaf.ComponentUI.getBaselineResizeBehavior.

Returns an enum indicating how the baseline of the component changes as the size changes.

public Rectangle
getCellBounds(JList<?> list, int index1, int index2)

Implements abstract javax.swing.plaf.ListUI.getCellBounds.

Returns the bounding rectangle, in the given list's coordinate system, for the range of cells specified by the two indices.

private Rectangle
getCellBounds(JList<?> list, int index)

Gets the bounds of the specified model index, returning the resulting bounds, or null if index is not valid.

private Rectangle
private BasicListUI.Handler
private int
getHeight(int column, int row)

Returns the height of the cell at the passed in location.

pack-priv InputMap
getInputMap(int condition)

private int
getModelIndex(int column, int row)

Returns the model index for the specified display location.

public Dimension

Returns:

The total size of the list.
getPreferredSize
(JComponent
The JList component.
c
)

Overrides javax.swing.plaf.ComponentUI.getPreferredSize.

The preferredSize of the list depends upon the layout orientation.

private int
getRowCount(int column)

Returns the number of rows in the given column.

protected int

Returns:

the specified row height or -1 if row isn't valid
getRowHeight
(int
a row
row
)

Returns the height of the specified row based on the current layout.

public Point
indexToLocation(JList<?> list, int index)

Implements abstract javax.swing.plaf.ListUI.indexToLocation.

Returns the origin in the given JList, of the specified item, in the list's coordinate system.

protected void
installDefaults()

Initializes list properties such as font, foreground, and background, and adds the CellRendererPane.

protected void
installKeyboardActions()

Registers the keyboard bindings on the JList that the BasicListUI is associated with.

protected void
installListeners()

Creates and installs the listeners for the JList, its model, and its selectionModel.

public void
installUI(JComponent c)

Overrides javax.swing.plaf.ComponentUI.installUI.

Initializes this.list by calling installDefaults(), installListeners(), and installKeyboardActions() in order.

pack-priv static void
public int
locationToIndex(JList<?> list, Point location)

Implements abstract javax.swing.plaf.ListUI.locationToIndex.

Returns the cell index in the specified JList closest to the given location in the list's coordinate system.

protected void
maybeUpdateLayoutState()

If updateLayoutStateNeeded is non zero, call updateLayoutState() and reset updateLayoutStateNeeded.

public void
paint(Graphics g, JComponent c)

Overrides javax.swing.plaf.ComponentUI.paint.

Paint the rows that intersect the Graphics objects clipRect.

protected void
paintCell(Graphics
an instance of Graphics
g
,
int
a row
row
,
Rectangle
a bounding rectangle to render to
rowBounds
,
ListCellRenderer<Object>
a list of ListCellRenderer
cellRenderer
,
ListModel<Object>
a list model
dataModel
,
ListSelectionModel
a selection model
selModel
,
int
a lead index
leadIndex
)

Paint one List cell: compute the relevant state, get the "rubber stamp" cell renderer component, and then use the CellRendererPane to paint it.

private void
private void
private void
protected void
selectNextIndex()

Selected the previous row and force it to be visible.

protected void
selectPreviousIndex()

Selected the previous row and force it to be visible.

protected void
uninstallDefaults()

Sets the list properties that have not been explicitly overridden to null.

protected void
uninstallKeyboardActions()

Unregisters keyboard actions installed from installKeyboardActions.

protected void
uninstallListeners()

Removes the listeners from the JList, its model, and its selectionModel.

public void
uninstallUI(JComponent c)

Overrides javax.swing.plaf.ComponentUI.uninstallUI.

Uninitializes this.list by calling uninstallListeners(), uninstallKeyboardActions(), and uninstallDefaults() in order.

private void
updateHorizontalLayoutState(int fixedCellWidth, int fixedCellHeight)

Invoked when the list is laid out horizontally to determine how many columns to create.

private void
protected void
updateLayoutState()

Recompute the value of cellHeight or cellHeights based and cellWidth, based on the current font and the current values of fixedCellWidth, fixedCellHeight, and prototypeCellValue.