Prev Class | Next Class | Frames | No Frames |
Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
java.lang.Object
javax.swing.plaf.ComponentUI
javax.swing.plaf.ListUI
javax.swing.plaf.basic.BasicListUI
public class BasicListUI
extends ListUI
Nested Class Summary | |
class |
|
class |
|
class |
|
class |
|
class |
|
Field Summary | |
protected int |
|
protected int[] |
|
protected static int |
|
protected int |
|
protected static int |
|
protected static int |
|
protected FocusListener |
|
protected static int |
|
protected JList |
|
protected ListDataListener |
|
protected ListSelectionListener |
|
protected static int |
|
protected MouseInputListener |
|
protected PropertyChangeListener |
|
protected static int |
|
protected CellRendererPane |
|
protected static int |
|
protected int |
|
Constructor Summary | |
|
Method Summary | |
protected int |
|
protected int |
|
protected FocusListener |
|
protected ListDataListener |
|
protected ListSelectionListener |
|
protected MouseInputListener |
|
protected PropertyChangeListener |
|
static ComponentUI |
|
Rectangle |
|
Dimension |
|
protected int |
|
Point |
|
protected void |
|
protected void |
|
protected void |
|
void |
|
int |
|
protected void |
|
void |
|
protected void |
|
protected void |
|
protected void |
|
protected void |
|
protected void |
|
protected void |
|
void |
|
protected void |
|
Methods inherited from class javax.swing.plaf.ListUI | |
getCellBounds , indexToLocation , locationToIndex |
Methods inherited from class javax.swing.plaf.ComponentUI | |
contains , createUI , getAccessibleChild , getAccessibleChildrenCount , getMaximumSize , getMinimumSize , getPreferredSize , installUI , paint , uninstallUI , update |
Methods inherited from class java.lang.Object | |
clone , equals , extends Object> getClass , finalize , hashCode , notify , notifyAll , toString , wait , wait , wait |
protected int cellHeight
The height of a single cell in the list. This field is used when the fixedCellHeight property of the list is set. Otherwise this field is set to-1
andcellHeights
is used instead.
protected int[] cellHeights
An array of varying heights of cells in the list, in cases where each cell might have a different height. This field is used when thefixedCellHeight
property of the list is not set. Otherwise this field isnull
andcellHeight
is used.
protected static final int cellRendererChanged
A constant to indicate that the cellRenderer has changed.
- Field Value:
- 64
protected static final int fixedCellHeightChanged
A constant to indicate that the fixedCellHeight has changed.
- Field Value:
- 16
protected static final int fixedCellWidthChanged
A constant to indicate that the fixedCellWidth has changed.
- Field Value:
- 8
protected static final int fontChanged
A constant to indicate that the font has changed.
- Field Value:
- 4
protected ListDataListener listDataListener
The data listener listening to the model.
protected ListSelectionListener listSelectionListener
The selection listener listening to the selection model.
protected static final int modelChanged
A constant to indicate that the model has changed.
- Field Value:
- 1
protected MouseInputListener mouseInputListener
The mouse listener listening to the list.
protected PropertyChangeListener propertyChangeListener
The property change listener listening to the list.
protected static final int prototypeCellValueChanged
A constant to indicate that the prototypeCellValue has changed.
- Field Value:
- 32
protected static final int selectionModelChanged
A constant to indicate that the selection model has changed.
- Field Value:
- 2
protected int updateLayoutStateNeeded
A bitmask that indicates which properties of the JList have changed. When nonzero, indicates that the UI class is out of date with respect to the underlying list, and must recalculate the list layout before painting or performing size calculations.
protected int convertRowToY(int row)
Calculate the Y coordinate of the upper edge of a particular row, considering the Y coordinate0
to occur at the top of the list.
- Parameters:
row
- The row to calculate the Y coordinate of
- Returns:
- The Y coordinate of the specified row, or
-1
if the specified row number is invalid
protected int convertYToRow(int y0)
Calculate the row number containing a particular Y coordinate, considering the Y coodrinate0
to occur at the top of the list.
- Parameters:
y0
- The Y coordinate to calculate the row number for
- Returns:
- The row number containing the specified Y value, or
-1
if the list model is empty
protected FocusListener createFocusListener()
Creates and returns the focus listener for this UI.
- Returns:
- the focus listener for this UI
protected ListDataListener createListDataListener()
Creates and returns the list data listener for this UI.
- Returns:
- the list data listener for this UI
protected ListSelectionListener createListSelectionListener()
Creates and returns the list selection listener for this UI.
- Returns:
- the list selection listener for this UI
protected MouseInputListener createMouseInputListener()
Creates and returns the mouse input listener for this UI.
- Returns:
- the mouse input listener for this UI
protected PropertyChangeListener createPropertyChangeListener()
Creates and returns the property change listener for this UI.
- Returns:
- the property change listener for this UI
public static ComponentUI createUI(JComponent c)
Creates a new BasicListUI for the component.
- Overrides:
- createUI in interface ComponentUI
- Parameters:
c
- The component to create a UI for
- Returns:
- A new UI
public Rectangle getCellBounds(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)
.
- Overrides:
- getCellBounds in interface ListUI
- Parameters:
l
- Ignored; calculates overthis.list
index1
- The first row to include in the boundsindex2
- The last row to incude in the bounds
- Returns:
- A rectangle encompassing the range of rows between
index1
andindex2
inclusive, or null such a rectangle couldn't be calculated for the given indexes.
public Dimension getPreferredSize(JComponent c)
Gets the size this list would prefer to assume. This is calculated by callinggetCellBounds(JList,int,int)
over the entire list.
- Overrides:
- getPreferredSize in interface ComponentUI
- Parameters:
c
- Ignored; uses the savedJList
reference
- Returns:
- DOCUMENT ME!
protected int getRowHeight(int row)
Calculate the height of a particular row. If there is a fixedcellHeight
, return it; otherwise return the specific row height requested from thecellHeights
array. If the requested row is invalid, return-1
.
- Parameters:
row
- The row to get the height of
- Returns:
- The height, in pixels, of the specified row
public Point indexToLocation(JList l, int index)
Determines the location of the specified cell.
- Overrides:
- indexToLocation in interface ListUI
- Parameters:
index
- the zero-based index of the cell whose location shall be determined.
- Returns:
- the position of the top left corner of the cell in the
JList
coordinate system, ornull
ifcell
does not designate a valid cell.
protected void installDefaults()
Installs various default settings (mostly colors) from theUIDefaults
into theJList
- See Also:
uninstallDefaults()
protected void installKeyboardActions()
Installs keyboard actions for this UI in theJList
.
protected void installListeners()
Attaches all the listeners we have in the UI class to theJList
, its model and its selection model.
- See Also:
uninstallListeners()
public void installUI(JComponent c)
Installs the various aspects of the UI in theJList
. In particular, callsinstallDefaults()
,installListeners()
andinstallKeyboardActions()
. Also saves a reference to the provided component, cast to aJList
.
- Overrides:
- installUI in interface ComponentUI
- Parameters:
c
- TheJList
to install the UI into
public int locationToIndex(JList l, Point location)
Computes the index of a list cell given a point within the list. If the location lies outside the bounds of the list, the greatest index in the list model is returned.
- Overrides:
- locationToIndex in interface ListUI
- Parameters:
l
- the list which on which the computation is based onlocation
- the coordinates
- Returns:
- the index of the list item that is located at the given coordinates or
-1
if the list model is empty
protected void maybeUpdateLayoutState()
CallsupdateLayoutState()
ifupdateLayoutStateNeeded
is nonzero, then resetsupdateLayoutStateNeeded
to zero.
public void paint(Graphics g, JComponent c)
Paints the list by repeatedly callingpaintCell(Graphics,int,Rectangle,ListCellRenderer,ListModel,ListSelectionModel,int)
for each visible cell in the list.
- Overrides:
- paint in interface ComponentUI
- Parameters:
g
- The graphics context to paint withc
- Ignored; uses the savedJList
reference
protected void paintCell(Graphics g, int row, Rectangle bounds, ListCellRenderer rend, ListModel data, ListSelectionModel sel, int lead)
Paints a single cell in the list.
- Parameters:
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 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 tonull
those defaults which were installed ininstallDefaults()
protected void uninstallKeyboardActions()
Uninstalls keyboard actions for this UI in theJList
.
protected void uninstallListeners()
Detaches all the listeners we attached ininstallListeners()
.
public void uninstallUI(JComponent c)
Uninstalls all the aspects of the UI which were installed ininstallUI(JComponent)
. When finished uninstalling, drops the saved reference to theJList
.
- Overrides:
- uninstallUI in interface ComponentUI
- Parameters:
c
- Ignored; the UI is uninstalled from theJList
reference saved during the call toinstallUI(JComponent)
protected void updateLayoutState()
Recomputes thecellHeights
,cellHeight
, andcellWidth
properties by examining the variouis properties of theJList
.