SynthListUIpublic class BasicListUI extends ListUI
ListUI.  BasicListUI instances cannot be shared between multiple lists.
| Modifier and Type | Class | Description | 
|---|---|---|
| class  | BasicListUI.FocusHandler | This class should be treated as a "protected" inner class. | 
| class  | BasicListUI.ListDataHandler | The  ListDataListenerthat's added to theJListsmodel atinstallUI time, and whenever the JList.model property changes. | 
| class  | BasicListUI.ListSelectionHandler | The ListSelectionListener that's added to the JLists selection model at installUI time, and whenever the JList.selectionModel property changes. | 
| class  | BasicListUI.MouseInputHandler | Mouse input, and focus handling for JList. | 
| class  | BasicListUI.PropertyChangeHandler | The PropertyChangeListener that's added to the JList at installUI time. | 
| Modifier and Type | Field | Description | 
|---|---|---|
| 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. | 
| 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 | FocusListenerthat attached toJList. | 
| protected static final int | fontChanged | The bit relates to font changed property. | 
| protected JList | list | The instance of  JList. | 
| protected ListDataListener | listDataListener | ListDataListenerthat attached toJList. | 
| protected ListSelectionListener | listSelectionListener | ListSelectionListenerthat attached toJList. | 
| protected static final int | modelChanged | The bit relates to model changed property. | 
| protected MouseInputListener | mouseInputListener | MouseInputListenerthat attached toJList. | 
| protected PropertyChangeListener | propertyChangeListener | PropertyChangeListenerthat attached toJList. | 
| protected static final int | prototypeCellValueChanged | The bit relates to prototype cell value changed property. | 
| protected CellRendererPane | rendererPane | The instance of  CellRendererPane. | 
| protected static final int | selectionModelChanged | The bit relates to selection model changed property. | 
| protected int | updateLayoutStateNeeded | The value represents changes to  JListmodel. | 
| Constructor | Description | 
|---|---|
| BasicListUI() | Constructs a  BasicListUI. | 
| Modifier and Type | Method | Description | 
|---|---|---|
| protected int | convertRowToY | Return the  JListrelative Y coordinate of the origin of the specified row or -1 if row isn't valid. | 
| protected int | convertYToRow | Convert the  JListrelative coordinate to the row that contains it, based on the current layout. | 
| protected FocusListener | createFocusListener() | Returns an instance of  FocusListener. | 
| protected ListDataListener | createListDataListener() | Creates an instance of  ListDataListenerthat's added to theJListsby model as needed. | 
| protected ListSelectionListener | createListSelectionListener() | Creates an instance of  ListSelectionHandlerthat's added to theJListsby selectionModel as needed. | 
| protected MouseInputListener | createMouseInputListener() | Creates a delegate that implements  MouseInputListener. | 
| protected PropertyChangeListener | createPropertyChangeListener() | Creates an instance of  PropertyChangeHandlerthat's added to theJListbyinstallUI(). | 
| static ComponentUI | createUI | Returns a new instance of  BasicListUI. | 
| int | getBaseline | Returns the baseline. | 
| Component.BaselineResizeBehavior | getBaselineResizeBehavior | Returns an enum indicating how the baseline of the component changes as the size changes. | 
| Rectangle | getCellBounds | Returns the bounding rectangle, in the given list's coordinate system, for the range of cells specified by the two indices. | 
| Dimension | getPreferredSize | The preferredSize of the list depends upon the layout orientation. | 
| protected int | getRowHeight | Returns the height of the specified row based on the current layout. | 
| Point | 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  JListthat theBasicListUIis associated with. | 
| protected void | installListeners() | Creates and installs the listeners for the JList, its model, and its selectionModel. | 
| void | installUI | Initializes  this.listby callinginstallDefaults(),installListeners(), andinstallKeyboardActions()in order. | 
| int | locationToIndex | Returns the cell index in the specified  JListclosest to the given location in the list's coordinate system. | 
| protected void | maybeUpdateLayoutState() | If updateLayoutStateNeeded is non zero, call updateLayoutState() and reset updateLayoutStateNeeded. | 
| void | paint | Paint the rows that intersect the Graphics objects clipRect. | 
| protected void | paintCell | Paint one List cell: compute the relevant state, get the "rubber stamp" cell renderer component, and then use the  CellRendererPaneto paint it. | 
| 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. | 
| void | uninstallUI | Uninitializes  this.listby callinguninstallListeners(),uninstallKeyboardActions(), anduninstallDefaults()in order. | 
| 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. | 
contains, getAccessibleChild, getAccessibleChildrenCount, getMaximumSize, getMinimumSize, update
protected JList<Object> list
JList.protected CellRendererPane rendererPane
CellRendererPane.protected FocusListener focusListener
FocusListener that attached to JList.protected MouseInputListener mouseInputListener
MouseInputListener that attached to JList.protected ListSelectionListener listSelectionListener
ListSelectionListener that attached to JList.protected ListDataListener listDataListener
ListDataListener that attached to JList.protected PropertyChangeListener propertyChangeListener
PropertyChangeListener that attached to JList.protected int[] cellHeights
protected int cellHeight
protected int cellWidth
protected int updateLayoutStateNeeded
JList model.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
public BasicListUI()
BasicListUI.protected void paintCell(Graphics g, int row, Rectangle rowBounds, ListCellRenderer<Object> cellRenderer, ListModel<Object> dataModel, ListSelectionModel selModel, int leadIndex)
CellRendererPane to paint it. Subclasses may want to override this method rather than paint().g - an instance of Graphics
row - a rowrowBounds - a bounding rectangle to render tocellRenderer - a list of ListCellRenderer
dataModel - a list modelselModel - a selection modelleadIndex - a lead indexpublic void paint(Graphics g, JComponent c)
paint in class ComponentUI
g - the Graphics context in which to paintc - the component being painted; this argument is often ignored, but might be used if the UI object is stateless and shared by multiple componentspublic int getBaseline(JComponent c, int width, int height)
getBaseline in class ComponentUI
c - JComponent baseline is being requested forwidth - the width to get the baseline forheight - the height to get the baseline forNullPointerException - if c is null
IllegalArgumentException - if width or height is < 0public Component.BaselineResizeBehavior getBaselineResizeBehavior(JComponent c)
getBaselineResizeBehavior in class ComponentUI
c - JComponent to return baseline resize behavior forNullPointerException - if c is null
public Dimension getPreferredSize(JComponent c)
| Layout Orientation | Preferred Size | 
|---|---|
| JList.VERTICAL | The preferredSize of the 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 fixedCellWidth is specified then we just use that. | 
| JList.VERTICAL_WRAP | If the visible row count is greater than zero, the preferredHeight is the maximum cell height * visibleRowCount. If the visible row count is <= 0, the preferred height is either the current height of the list, or the maximum cell height, whichever is bigger. The preferred width is than the maximum cell width * number of columns needed. Where the number of columns needs is list.height / max cell height. Max cell height is either the fixed cell height, or is determined by iterating through all the cells to find the maximum height from the ListCellRenderer. | 
| JList.HORIZONTAL_WRAP | If the visible row count is greater than zero, the preferredHeight is the maximum cell height * adjustedRowCount. Where visibleRowCount is used to determine the number of columns. Because this lays out horizontally the number of rows is then determined from the column count. For example, lets say you have a model with 10 items and the visible row count is 8. The number of columns needed to display this is 2, but you no longer need 8 rows to display this, you only need 5, thus the adjustedRowCount is 5.  If the visible row count is <= 0, the preferred height is dictated by the number of columns, which will be as many as can fit in the width of the  | 
Insets are determined from list.getInsets().getPreferredSize in class ComponentUI
c - The JList component.protected void selectPreviousIndex()
protected void selectNextIndex()
protected void installKeyboardActions()
JList that the BasicListUI is associated with. This method is called at installUI() time.protected void uninstallKeyboardActions()
installKeyboardActions. This method is called at uninstallUI() time - subclassess should ensure that all of the keyboard actions registered at installUI time are removed here.protected void installListeners()
protected void uninstallListeners()
protected void installDefaults()
protected void uninstallDefaults()
null. A property is considered overridden if its current value is not a UIResource.public void installUI(JComponent c)
this.list by calling installDefaults(), installListeners(), and installKeyboardActions() in order.installUI in class ComponentUI
c - the component where this UI delegate is being installedpublic void uninstallUI(JComponent c)
this.list by calling uninstallListeners(), uninstallKeyboardActions(), and uninstallDefaults() in order. Sets this.list to null.uninstallUI in class ComponentUI
c - the component from which this UI delegate is being removed; this argument is often ignored, but might be used if the UI object is stateless and shared by multiple componentspublic static ComponentUI createUI(JComponent list)
BasicListUI. BasicListUI delegates are allocated one per JList.list - a componentListUI implementation for the Windows look and feel.public int locationToIndex(JList<?> list, Point location)
JList closest to the given location in the list's coordinate system. To determine if the cell actually contains the specified location, compare the point against the cell's bounds, as provided by getCellBounds. This method returns -1 if the list's model is empty.locationToIndex in class ListUI
list - the listlocation - the coordinates of the point-1
NullPointerException - if location is nullpublic Point indexToLocation(JList<?> list, int index)
JList, of the specified item, in the list's coordinate system. Returns null if the index isn't valid.indexToLocation in class ListUI
list - the listindex - the cell indexnull
public Rectangle getCellBounds(JList<?> list, int index1, int index2)
 If the smaller index is outside the list's range of cells, this method returns null. If the smaller index is valid, but the larger index is outside the list's range, the bounds of just the first index is returned. Otherwise, the bounds of the valid range is returned.
getCellBounds in class ListUI
list - the listindex1 - the first index in the rangeindex2 - the second index in the rangenull
protected int getRowHeight(int row)
row - a rowprotected int convertYToRow(int y0)
JList relative coordinate to the row that contains it, based on the current layout. If y0 doesn't fall within any row, return -1.y0 - a relative Y coordinateprotected int convertRowToY(int row)
JList relative Y coordinate of the origin of the specified row or -1 if row isn't valid.row - a rowprotected void maybeUpdateLayoutState()
protected void updateLayoutState()
protected MouseInputListener createMouseInputListener()
MouseInputListener. The delegate is added to the corresponding java.awt.Component listener lists at installUI() time. Subclasses can override this method to return a custom MouseInputListener, e.g. 
 class MyListUI extends BasicListUI {
    protected MouseInputListener createMouseInputListener() {
        return new MyMouseInputHandler();
    }
    public class MyMouseInputHandler extends MouseInputHandler {
        public void mouseMoved(MouseEvent e) {
            // do some extra work when the mouse moves
            super.mouseMoved(e);
        }
    }
 }
 
MouseInputListener
protected FocusListener createFocusListener()
FocusListener.FocusListener
protected ListSelectionListener createListSelectionListener()
ListSelectionHandler 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 createListSelectionListener() {
        return new MySelectionListener();
    }
    public class MySelectionListener extends ListSelectionHandler {
        public void valueChanged(ListSelectionEvent e) {
            // do some extra work when the selection changes
            super.valueChange(e);
        }
    }
 }
 
ListSelectionHandler
protected ListDataListener createListDataListener()
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 createListDataListener() {
        return new MyListDataListener();
    }
    public class MyListDataListener extends ListDataHandler {
        public void contentsChanged(ListDataEvent e) {
            // do some extra work when the models contents change
            super.contentsChange(e);
        }
    }
 }
 
ListDataListener
protected PropertyChangeListener createPropertyChangeListener()
PropertyChangeHandler 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 createPropertyChangeListener() {
        return new MyPropertyChangeListener();
    }
    public class MyPropertyChangeListener extends PropertyChangeHandler {
        public void propertyChange(PropertyChangeEvent e) {
            if (e.getPropertyName().equals("model")) {
                // do some extra work when the model changes
            }
            super.propertyChange(e);
        }
    }
 }
 
PropertyChangeHandler
    © 1993, 2023, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
    https://docs.oracle.com/en/java/javase/21/docs/api/java.desktop/javax/swing/plaf/basic/BasicListUI.html