public class BasicListUI extends javax.swing.plaf.ListUI
| Modifier and Type | Class and Description |
|---|---|
class |
BasicListUI.FocusHandler
A helper class which listens for
FocusEvents
from the JList. |
class |
BasicListUI.ListDataHandler
A helper class which listens for
ListDataEvents generated by
the JList's ListModel. |
class |
BasicListUI.ListSelectionHandler
A helper class which listens for
ListSelectionEvents
from the JList's ListSelectionModel. |
class |
BasicListUI.MouseInputHandler
A helper class which listens for
MouseEvents
from the JList. |
class |
BasicListUI.PropertyChangeHandler
Helper class which listens to
PropertyChangeEvents
from the JList. |
| Modifier and Type | Field and Description |
|---|---|
protected int |
cellHeight
The height of a single cell in the list.
|
protected int[] |
cellHeights
An array of varying heights of cells in the list, in cases where each
cell might have a different height.
|
protected static int |
cellRendererChanged
A constant to indicate that the cellRenderer has changed.
|
protected int |
cellWidth
The width of a single cell in the list.
|
protected static int |
fixedCellHeightChanged
A constant to indicate that the fixedCellHeight has changed.
|
protected static int |
fixedCellWidthChanged
A constant to indicate that the fixedCellWidth has changed.
|
protected java.awt.event.FocusListener |
focusListener
The current focus listener.
|
protected static int |
fontChanged
A constant to indicate that the font has changed.
|
protected javax.swing.JList |
list
Saved reference to the list this UI was created for.
|
protected javax.swing.event.ListDataListener |
listDataListener
The data listener listening to the model.
|
protected javax.swing.event.ListSelectionListener |
listSelectionListener
The selection listener listening to the selection model.
|
protected static int |
modelChanged
A constant to indicate that the model has changed.
|
protected javax.swing.event.MouseInputListener |
mouseInputListener
The mouse listener listening to the list.
|
protected java.beans.PropertyChangeListener |
propertyChangeListener
The property change listener listening to the list.
|
protected static int |
prototypeCellValueChanged
A constant to indicate that the prototypeCellValue has changed.
|
protected javax.swing.CellRendererPane |
rendererPane
The
CellRendererPane that is used for painting. |
protected static int |
selectionModelChanged
A constant to indicate that the selection model has changed.
|
protected int |
updateLayoutStateNeeded
A bitmask that indicates which properties of the JList have changed.
|
| Constructor and Description |
|---|
BasicListUI()
Creates a new BasicListUI object.
|
| Modifier and Type | Method and Description |
|---|---|
protected int |
convertRowToY(int row)
Calculate the Y coordinate of the upper edge of a particular row,
considering the Y coordinate
0 to occur at the top of the
list. |
protected int |
convertYToRow(int y0)
Calculate the row number containing a particular Y coordinate,
considering the Y coodrinate
0 to occur at the top of the
list. |
protected java.awt.event.FocusListener |
createFocusListener()
Creates and returns the focus listener for this UI.
|
protected javax.swing.event.ListDataListener |
createListDataListener()
Creates and returns the list data listener for this UI.
|
protected javax.swing.event.ListSelectionListener |
createListSelectionListener()
Creates and returns the list selection listener for this UI.
|
protected javax.swing.event.MouseInputListener |
createMouseInputListener()
Creates and returns the mouse input listener for this UI.
|
protected java.beans.PropertyChangeListener |
createPropertyChangeListener()
Creates and returns the property change listener for this UI.
|
static javax.swing.plaf.ComponentUI |
createUI(javax.swing.JComponent c)
Creates a new BasicListUI for the component.
|
java.awt.Rectangle |
getCellBounds(javax.swing.JList l,
int index1,
int index2)
Calculate the bounds of a particular cell, considering the upper left
corner of the list as the origin position
(0,0). |
java.awt.Dimension |
getPreferredSize(javax.swing.JComponent c)
Gets the size this list would prefer to assume.
|
protected int |
getRowHeight(int row)
Calculate the height of a particular row.
|
java.awt.Point |
indexToLocation(javax.swing.JList l,
int index)
Determines the location of the specified cell.
|
protected void |
installDefaults()
Installs various default settings (mostly colors) from the
UIDefaults into the JList |
protected void |
installKeyboardActions()
Installs keyboard actions for this UI in the
JList. |
protected void |
installListeners()
Attaches all the listeners we have in the UI class to the
JList, its model and its selection model. |
void |
installUI(javax.swing.JComponent c)
Installs the various aspects of the UI in the
JList. |
int |
locationToIndex(javax.swing.JList l,
java.awt.Point location)
Computes the index of a list cell given a point within the list.
|
protected void |
maybeUpdateLayoutState()
Calls
updateLayoutState() if updateLayoutStateNeeded
is nonzero, then resets updateLayoutStateNeeded to zero. |
void |
paint(java.awt.Graphics g,
javax.swing.JComponent c)
Paints the list by repeatedly calling
paintCell(java.awt.Graphics, int, java.awt.Rectangle, javax.swing.ListCellRenderer, javax.swing.ListModel, javax.swing.ListSelectionModel, int) for each visible
cell in the list. |
protected void |
paintCell(java.awt.Graphics g,
int row,
java.awt.Rectangle bounds,
javax.swing.ListCellRenderer rend,
javax.swing.ListModel data,
javax.swing.ListSelectionModel sel,
int lead)
Paints a single cell in the list.
|
protected void |
selectNextIndex()
Selects the next list item and force it to be visible.
|
protected void |
selectPreviousIndex()
Selects the previous list item and force it to be visible.
|
protected void |
uninstallDefaults()
Resets to
null those defaults which were installed in
installDefaults() |
protected void |
uninstallKeyboardActions()
Uninstalls keyboard actions for this UI in the
JList. |
protected void |
uninstallListeners()
Detaches all the listeners we attached in
installListeners(). |
void |
uninstallUI(javax.swing.JComponent c)
Uninstalls all the aspects of the UI which were installed in
installUI(javax.swing.JComponent). |
protected void |
updateLayoutState()
Recomputes the
cellHeights, cellHeight, and cellWidth properties by examining the variouis properties of the
JList. |
protected static final int modelChanged
protected static final int selectionModelChanged
protected static final int fontChanged
protected static final int fixedCellWidthChanged
protected static final int fixedCellHeightChanged
protected static final int prototypeCellValueChanged
protected static final int cellRendererChanged
protected java.awt.event.FocusListener focusListener
protected javax.swing.event.ListDataListener listDataListener
protected javax.swing.event.ListSelectionListener listSelectionListener
protected javax.swing.event.MouseInputListener mouseInputListener
protected java.beans.PropertyChangeListener propertyChangeListener
protected javax.swing.JList list
protected int cellHeight
-1 and cellHeights is used instead.protected int cellWidth
protected int[] cellHeights
fixedCellHeight property of the list is not set. Otherwise
this field is null and cellHeight is used.protected int updateLayoutStateNeeded
protected javax.swing.CellRendererPane rendererPane
CellRendererPane that is used for painting.public BasicListUI()
public static javax.swing.plaf.ComponentUI createUI(javax.swing.JComponent c)
c - The component to create a UI forprotected int getRowHeight(int row)
cellHeight, return it; otherwise return the specific row height
requested from the cellHeights array. If the requested row
is invalid, return -1.row - The row to get the height ofpublic java.awt.Rectangle getCellBounds(javax.swing.JList l, int index1, int index2)
(0,0).getCellBounds in class javax.swing.plaf.ListUIl - Ignored; calculates over this.listindex1 - The first row to include in the boundsindex2 - The last row to incude in the boundsindex1 and index2 inclusive, or null
such a rectangle couldn't be calculated for the given indexes.protected int convertRowToY(int row)
0 to occur at the top of the
list.row - The row to calculate the Y coordinate of-1 if
the specified row number is invalidprotected int convertYToRow(int y0)
0 to occur at the top of the
list.y0 - The Y coordinate to calculate the row number for-1
if the list model is emptyprotected void updateLayoutState()
cellHeights, cellHeight, and cellWidth properties by examining the variouis properties of the
JList.protected void maybeUpdateLayoutState()
updateLayoutState() if updateLayoutStateNeeded
is nonzero, then resets updateLayoutStateNeeded to zero.protected void installDefaults()
UIDefaults into the JListuninstallDefaults()protected void uninstallDefaults()
null those defaults which were installed in
installDefaults()protected void installListeners()
JList, its model and its selection model.uninstallListeners()protected void uninstallListeners()
installListeners().protected void installKeyboardActions()
JList.protected void uninstallKeyboardActions()
JList.public void installUI(javax.swing.JComponent c)
JList. In
particular, calls installDefaults(), installListeners()
and installKeyboardActions(). Also saves a reference to the
provided component, cast to a JList.installUI in class javax.swing.plaf.ComponentUIc - The JList to install the UI intoComponentUI.uninstallUI(javax.swing.JComponent),
JComponent.setUI(javax.swing.plaf.ComponentUI),
JComponent.updateUI()public void uninstallUI(javax.swing.JComponent c)
installUI(javax.swing.JComponent). When finished uninstalling, drops the saved reference to
the JList.uninstallUI in class javax.swing.plaf.ComponentUIc - Ignored; the UI is uninstalled from the JList
reference saved during the call to installUI(javax.swing.JComponent)ComponentUI.installUI(javax.swing.JComponent),
JComponent.setUI(javax.swing.plaf.ComponentUI),
JComponent.updateUI()public java.awt.Dimension getPreferredSize(javax.swing.JComponent c)
getCellBounds(javax.swing.JList, int, int) over the entire list.getPreferredSize in class javax.swing.plaf.ComponentUIc - Ignored; uses the saved JList referenceprotected void paintCell(java.awt.Graphics g, int row, java.awt.Rectangle bounds, javax.swing.ListCellRenderer rend, javax.swing.ListModel data, javax.swing.ListSelectionModel sel, int lead)
g - The graphics context to paint inrow - The row number to paintbounds - The bounds of the cell to paint, assuming a coordinate
system beginning at (0,0) in the upper left corner of the
listrend - A cell renderer to paint withdata - The data to provide to the cell renderersel - A selection model to provide to the cell rendererlead - The lead selection index of the listpublic void paint(java.awt.Graphics g, javax.swing.JComponent c)
paintCell(java.awt.Graphics, int, java.awt.Rectangle, javax.swing.ListCellRenderer, javax.swing.ListModel, javax.swing.ListSelectionModel, int) for each visible
cell in the list.paint in class javax.swing.plaf.ComponentUIg - The graphics context to paint withc - Ignored; uses the saved JList referencepublic int locationToIndex(javax.swing.JList l, java.awt.Point location)
locationToIndex in class javax.swing.plaf.ListUIl - the list which on which the computation is based onlocation - the coordinates-1 if the list model is emptypublic java.awt.Point indexToLocation(javax.swing.JList l, int index)
javax.swing.plaf.ListUIindexToLocation in class javax.swing.plaf.ListUIl - the JList for which this delegate object
provides the pluggable user interface.index - the zero-based index of the cell whose location shall be
determined.JList coordinate system, or null
if cell does not designate a valid cell.protected java.awt.event.FocusListener createFocusListener()
protected javax.swing.event.ListDataListener createListDataListener()
protected javax.swing.event.ListSelectionListener createListSelectionListener()
protected javax.swing.event.MouseInputListener createMouseInputListener()
protected java.beans.PropertyChangeListener createPropertyChangeListener()
protected void selectNextIndex()
protected void selectPreviousIndex()