All Packages Class Hierarchy This Package Previous Next Index
Class com.sun.java.swing.basic.BasicListUI
java.lang.Object
|
+----com.sun.java.swing.plaf.ComponentUI
|
+----com.sun.java.swing.plaf.ListUI
|
+----com.sun.java.swing.basic.BasicListUI
- public class BasicListUI
- extends ListUI
- implements Serializable
A Windows L&F implementation of ListUI.
-
cellHeight
-
-
cellHeights
-
-
cellRendererChanged
-
-
cellWidth
-
-
dataL
-
-
defaultFont
-
-
defaultRowBackground
-
-
defaultRowForeground
-
-
fixedCellHeightChanged
-
-
fixedCellWidthChanged
-
-
fontChanged
-
-
hasFocus
- True if the JList has the focus.
-
inputL
-
-
leadRowHighlight
-
-
list
-
-
modelChanged
-
-
propertyL
-
-
prototypeCellValueChanged
-
-
rendererPane
-
-
selectedRowBackground
-
-
selectedRowForeground
-
-
selectionL
-
-
selectionModelChanged
-
-
updateLayoutStateNeeded
-
-
BasicListUI()
-
-
addListListeners()
- Create and install the listeners for the JList, its model, and its
selectionModel.
-
configureList()
- Initialize JList properties, e.g.
-
convertRowToY(int)
- Return the JList relative Y coordinate of the origin of the specified
row or -1 if row isn't valide.
-
convertYToRow(int)
- Convert the JList relative coordinate to the row that contains it,
based on the current layout.
-
createDataListener()
- Creates an instance of ListDataListener that's added to
the JLists by model as needed.
-
createInputListener()
- Creates a delegate that implements MouseListener, MouseMotionListener,
and FocusListener.
-
createPropertyListener()
- Creates an instance of PropertyChangeListener that's added to
the JList by installUI().
-
createSelectionListener()
- Creates an instance of ListSelectionListener that's added to
the JLists by selectionModel as needed.
-
createUI(JComponent)
- Returns a new instance of BasicListUI.
-
getCellBounds(JList, int, int)
-
-
getMaximumSize(JComponent)
-
-
getMinimumSize(JComponent)
-
-
getPreferredSize(JComponent)
- The preferredSize of a list is total height of the rows
and the maximum width of the cells.
-
getRowHeight(int)
- Returns the height of the specified row based on the current layout.
-
indexToLocation(JList, int)
-
-
installUI(JComponent)
-
-
locationToIndex(JList, Point)
-
-
maybeUpdateLayoutState()
- If updateLayoutStateNeeded is non zero, call updateLayoutState() and reset
updateLayoutStateNeeded.
-
paint(Graphics, JComponent)
- Paint the rows that intersect the Graphics objects clipRect.
-
paintBackground(Graphics)
- If the list is opaque, paint its background.
-
paintCell(Graphics, int, Rectangle, ListCellRenderer, ListModel, ListSelectionModel, int)
- Paint one List cell: compute the relevant state, get the "rubber stamp"
cell renderer component, and then use the CellRendererPane to paint it.
-
registerKeyboardActions()
- Register keyboard actions for the up and down arrow keys.
-
removeListListeners()
- Remove the listeners for the JList, its model, and its
selectionModel.
-
selectNextIndex()
- Selected the previous row and force it to be visible.
-
selectPreviousIndex()
- Selected the previous row and force it to be visible.
-
uninstallUI(JComponent)
-
-
unregisterKeyboardActions()
- Unregister keyboard actions for the up and down arrow keys.
-
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.
selectedRowBackground
protected static final Color selectedRowBackground
selectedRowForeground
protected static final Color selectedRowForeground
defaultRowBackground
protected static final Color defaultRowBackground
defaultRowForeground
protected static final Color defaultRowForeground
leadRowHighlight
protected static final Color leadRowHighlight
defaultFont
protected static final Font defaultFont
hasFocus
protected transient boolean hasFocus
- True if the JList has the focus. We cache this value rather than
relying on JComponent.hasFocus() as it's consulted per cell at
paint time.
#see InputListener
selectionL
protected ListSelectionListener selectionL
dataL
protected ListDataListener dataL
propertyL
protected PropertyChangeListener propertyL
inputL
protected BasicListUI. InputListener inputL
list
protected JList list
rendererPane
protected CellRendererPane rendererPane
cellHeights
protected int cellHeights[]
cellHeight
protected int cellHeight
cellWidth
protected int cellWidth
updateLayoutStateNeeded
protected int updateLayoutStateNeeded
modelChanged
protected static final int modelChanged
selectionModelChanged
protected static final int selectionModelChanged
fontChanged
protected static final int fontChanged
fixedCellWidthChanged
protected static final int fixedCellWidthChanged
fixedCellHeightChanged
protected static final int fixedCellHeightChanged
prototypeCellValueChanged
protected static final int prototypeCellValueChanged
cellRendererChanged
protected static final int cellRendererChanged
BasicListUI
public BasicListUI()
paintBackground
protected void paintBackground(Graphics g)
- If the list is opaque, paint its background.
Subclasses may want to override this method rather than paint().
- See Also:
- paint
paintCell
protected void paintCell(Graphics g,
int row,
Rectangle rowBounds,
ListCellRenderer cellRenderer,
ListModel dataModel,
ListSelectionModel selModel,
int leadIndex)
- Paint one List cell: compute the relevant state, get the "rubber stamp"
cell renderer component, and then use the CellRendererPane to paint it.
Subclasses may want to override this method rather than paint().
- See Also:
- paint
paint
public void paint(Graphics g,
JComponent c)
- Paint the rows that intersect the Graphics objects clipRect. This
method calls paintBackground and paintCell as necessary. Subclasses
may want to override these methods.
- Overrides:
- paint in class ComponentUI
- See Also:
- paintBackground, paintCell
getPreferredSize
public Dimension getPreferredSize(JComponent c)
- The preferredSize of a list is total height of the rows
and the maximum width of the cells. If JList.fixedCellHeight
is specified then the total height of the rows is just
(cellVerticalMargins + fixedCellHeight) * model.getSize() where
rowVerticalMargins is the space we allocate for drawing
the yellow focus outline. Similarly if JListfixedCellWidth is
specified then we just use that plus the horizontal margins.
- Parameters:
- c - The JList component.
- Returns:
- The total size of the list.
- Overrides:
- getPreferredSize in class ComponentUI
getMinimumSize
public Dimension getMinimumSize(JComponent c)
- Returns:
- s The preferred size.
- Overrides:
- getMinimumSize in class ComponentUI
- See Also:
- getPreferredSize
getMaximumSize
public Dimension getMaximumSize(JComponent c)
- Returns:
- s The preferred size.
- Overrides:
- getMaximumSize in class ComponentUI
- See Also:
- getPreferredSize
selectPreviousIndex
protected void selectPreviousIndex()
- Selected the previous row and force it to be visible.
Called by the KeyEvent.VK_UP keyboard action.
- See Also:
- registerKeyboardActions, ensureIndexIsVisible
selectNextIndex
protected void selectNextIndex()
- Selected the previous row and force it to be visible.
Called by the KeyEvent.VK_DOWN keyboard action.
- See Also:
- registerKeyboardActions, ensureIndexIsVisible
registerKeyboardActions
protected void registerKeyboardActions()
- Register keyboard actions for the up and down arrow keys. The
actions just call out to protected methods, subclasses that
want to override or extend keyboard behavior should consider
just overriding those methods. This method is called at
installUI() time.
- See Also:
- selectPreviousIndex, selectNextIndex, installUI
unregisterKeyboardActions
protected void unregisterKeyboardActions()
- Unregister keyboard actions for the up and down arrow keys.
This method is called at uninstallUI() time - subclassess should
ensure that all of the keyboard actions registered at installUI
time are removed here.
- See Also:
- selectPreviousIndex, selectNextIndex, installUI
addListListeners
protected void addListListeners()
- Create and install the listeners for the JList, its model, and its
selectionModel. This method is called at installUI() time.
- See Also:
- installUI, removeListListeners
removeListListeners
protected void removeListListeners()
- Remove the listeners for the JList, its model, and its
selectionModel. All of the listener fields, are reset to
null here. This method is called at uninstallUI() time,
it should be kept in sync with addListListeners.
- See Also:
- uninstallUI, addListListeners
configureList
protected void configureList()
- Initialize JList properties, e.g. font, foreground, and background,
and add the CellRendererPane.
- See Also:
- CellRendererPane
installUI
public void installUI(JComponent list)
- Overrides:
- installUI in class ComponentUI
- See Also:
- configureList, addListListeners, registerKeyboardActions
uninstallUI
public void uninstallUI(JComponent c)
- Overrides:
- uninstallUI in class ComponentUI
createUI
public static ComponentUI createUI(JComponent list)
- Returns a new instance of BasicListUI. BasicListUI delegates are
allocated one per JList.
- Returns:
- A new ListUI implementation for the Windows look and feel.
locationToIndex
public int locationToIndex(JList list,
Point location)
- Returns:
- The index of the cell at location, or -1.
- Overrides:
- locationToIndex in class ListUI
- See Also:
- locationToIndex
indexToLocation
public Point indexToLocation(JList list,
int index)
- Returns:
- The origin of the index'th cell.
- Overrides:
- indexToLocation in class ListUI
- See Also:
- indexToLocation
getCellBounds
public Rectangle getCellBounds(JList list,
int index1,
int index2)
- Returns:
- The bounds of the index'th cell.
- Overrides:
- getCellBounds in class ListUI
- See Also:
- getCellBounds
getRowHeight
protected int getRowHeight(int row)
- Returns the height of the specified row based on the current layout.
- Returns:
- The specified row height or -1 if row isn't valid.
- See Also:
- convertYToRow, convertRowToY, updateLayoutState
convertYToRow
protected int convertYToRow(int y0)
- Convert the JList relative coordinate to the row that contains it,
based on the current layout. If y0 doesn't fall within any row,
return -1.
- Returns:
- The row that contains y0, or -1.
- See Also:
- getRowHeight, updateLayoutState
convertRowToY
protected int convertRowToY(int row)
- Return the JList relative Y coordinate of the origin of the specified
row or -1 if row isn't valide.
- Returns:
- The Y coordinate of the origin of row, or -1.
- See Also:
- getRowHeight, updateLayout
maybeUpdateLayoutState
protected void maybeUpdateLayoutState()
- If updateLayoutStateNeeded is non zero, call updateLayoutState() and reset
updateLayoutStateNeeded. This method should be called by methods
before doing any computation based on the geometry of the list.
For example it's the first call in paint() and getPreferredSize().
- See Also:
- updateLayoutState
updateLayoutState
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.
- See Also:
- maybeUpdateLayoutState
createInputListener
protected BasicListUI. InputListener createInputListener()
- Creates a delegate that implements MouseListener, MouseMotionListener,
and FocusListener. The delegate is added to the corresponding
java.awt.Component listener lists at installUI() time. Subclasses can
override this method to return a custom InputListener, e.g.
class MyListUI extends BasicListUI {
protected InputListener createInputListener() {
return new MyInputListener();
}
protected class MyInputListener extends InputListener {
public void mouseMoved(MouseEvent e) {
// do some extra work when the mouse moves
super.mouseMoved(e);
}
}
}
- See Also:
- BasicListUI. InputListener, installUI
createSelectionListener
protected ListSelectionListener createSelectionListener()
- Creates an instance of ListSelectionListener that's added to
the JLists by selectionModel as needed. Subclasses can override
this method to return a custom ListSelectionListener, e.g.
class MyListUI extends BasicListUI {
protected ListSelectionListener createSelectionListener() {
return new MySelectionListener();
}
protected class MySelectionListener extends SelectionListener {
public void valueChanged(ListSelectionEvent e) {
// do some extra work when the selection changes
super.valueChange(e);
}
}
}
- See Also:
- BasicListUI. SelectionListener, installUI
createDataListener
protected ListDataListener createDataListener()
- Creates an instance of ListDataListener that's added to
the JLists by model as needed. Subclasses can override
this method to return a custom ListDataListener, e.g.
class MyListUI extends BasicListUI {
protected ListDataListener createDataListener() {
return new MyDataListener();
}
protected class MyDataListener extends DataListener {
public void contentsChanged(ListDataEvent e) {
// do some extra work when the models contents change
super.contentsChange(e);
}
}
}
- See Also:
- BasicListUI. DataListener, getModel, installUI
createPropertyListener
protected PropertyChangeListener createPropertyListener()
- Creates an instance of PropertyChangeListener that's added to
the JList by installUI(). Subclasses can override this method
to return a custom PropertyChangeListener, e.g.
class MyListUI extends BasicListUI {
protected PropertyChangeListener createPropertyListener() {
return new MyPropertyListener();
}
protected class MyPropertyListener extends PropertyListener {
public void propertyChange(PropertyChangeEvent e) {
if (e.getPropertyName().equals("model")) {
// do some extra work when the model changes
}
super.propertyChange(e);
}
}
}
- See Also:
- BasicListUI. PropertyListener, installUI
All Packages Class Hierarchy This Package Previous Next Index