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.


Variable Index

 o cellHeight
 o cellHeights
 o cellRendererChanged
 o cellWidth
 o dataL
 o defaultFont
 o defaultRowBackground
 o defaultRowForeground
 o fixedCellHeightChanged
 o fixedCellWidthChanged
 o fontChanged
 o hasFocus
True if the JList has the focus.
 o inputL
 o leadRowHighlight
 o list
 o modelChanged
 o propertyL
 o prototypeCellValueChanged
 o rendererPane
 o selectedRowBackground
 o selectedRowForeground
 o selectionL
 o selectionModelChanged
 o updateLayoutStateNeeded

Constructor Index

 o BasicListUI()

Method Index

 o addListListeners()
Create and install the listeners for the JList, its model, and its selectionModel.
 o configureList()
Initialize JList properties, e.g.
 o convertRowToY(int)
Return the JList relative Y coordinate of the origin of the specified row or -1 if row isn't valide.
 o convertYToRow(int)
Convert the JList relative coordinate to the row that contains it, based on the current layout.
 o createDataListener()
Creates an instance of ListDataListener that's added to the JLists by model as needed.
 o createInputListener()
Creates a delegate that implements MouseListener, MouseMotionListener, and FocusListener.
 o createPropertyListener()
Creates an instance of PropertyChangeListener that's added to the JList by installUI().
 o createSelectionListener()
Creates an instance of ListSelectionListener that's added to the JLists by selectionModel as needed.
 o createUI(JComponent)
Returns a new instance of BasicListUI.
 o getCellBounds(JList, int, int)
 o getMaximumSize(JComponent)
 o getMinimumSize(JComponent)
 o getPreferredSize(JComponent)
The preferredSize of a list is total height of the rows and the maximum width of the cells.
 o getRowHeight(int)
Returns the height of the specified row based on the current layout.
 o indexToLocation(JList, int)
 o installUI(JComponent)
 o locationToIndex(JList, Point)
 o maybeUpdateLayoutState()
If updateLayoutStateNeeded is non zero, call updateLayoutState() and reset updateLayoutStateNeeded.
 o paint(Graphics, JComponent)
Paint the rows that intersect the Graphics objects clipRect.
 o paintBackground(Graphics)
If the list is opaque, paint its background.
 o 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.
 o registerKeyboardActions()
Register keyboard actions for the up and down arrow keys.
 o removeListListeners()
Remove the listeners for the JList, its model, and its selectionModel.
 o selectNextIndex()
Selected the previous row and force it to be visible.
 o selectPreviousIndex()
Selected the previous row and force it to be visible.
 o uninstallUI(JComponent)
 o unregisterKeyboardActions()
Unregister keyboard actions for the up and down arrow keys.
 o 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.

Variables

 o selectedRowBackground
 protected static final Color selectedRowBackground
 o selectedRowForeground
 protected static final Color selectedRowForeground
 o defaultRowBackground
 protected static final Color defaultRowBackground
 o defaultRowForeground
 protected static final Color defaultRowForeground
 o leadRowHighlight
 protected static final Color leadRowHighlight
 o defaultFont
 protected static final Font defaultFont
 o 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

 o selectionL
 protected ListSelectionListener selectionL
 o dataL
 protected ListDataListener dataL
 o propertyL
 protected PropertyChangeListener propertyL
 o inputL
 protected BasicListUI. InputListener inputL
 o list
 protected JList list
 o rendererPane
 protected CellRendererPane rendererPane
 o cellHeights
 protected int cellHeights[]
 o cellHeight
 protected int cellHeight
 o cellWidth
 protected int cellWidth
 o updateLayoutStateNeeded
 protected int updateLayoutStateNeeded
 o modelChanged
 protected static final int modelChanged
 o selectionModelChanged
 protected static final int selectionModelChanged
 o fontChanged
 protected static final int fontChanged
 o fixedCellWidthChanged
 protected static final int fixedCellWidthChanged
 o fixedCellHeightChanged
 protected static final int fixedCellHeightChanged
 o prototypeCellValueChanged
 protected static final int prototypeCellValueChanged
 o cellRendererChanged
 protected static final int cellRendererChanged

Constructors

 o BasicListUI
 public BasicListUI()

Methods

 o 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
 o 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
 o 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
 o 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
 o getMinimumSize
 public Dimension getMinimumSize(JComponent c)
Returns:
s The preferred size.
Overrides:
getMinimumSize in class ComponentUI
See Also:
getPreferredSize
 o getMaximumSize
 public Dimension getMaximumSize(JComponent c)
Returns:
s The preferred size.
Overrides:
getMaximumSize in class ComponentUI
See Also:
getPreferredSize
 o 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
 o 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
 o 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
 o 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
 o 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
 o 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
 o configureList
 protected void configureList()
Initialize JList properties, e.g. font, foreground, and background, and add the CellRendererPane.

See Also:
CellRendererPane
 o installUI
 public void installUI(JComponent list)
Overrides:
installUI in class ComponentUI
See Also:
configureList, addListListeners, registerKeyboardActions
 o uninstallUI
 public void uninstallUI(JComponent c)
Overrides:
uninstallUI in class ComponentUI
 o 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.
 o 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
 o indexToLocation
 public Point indexToLocation(JList list,
                              int index)
Returns:
The origin of the index'th cell.
Overrides:
indexToLocation in class ListUI
See Also:
indexToLocation
 o 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
 o 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
 o 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
 o 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
 o 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
 o 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
 o 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
 o 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
 o 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
 o 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