Package org.jdesktop.swingx.plaf.basic
Class BasicYListUI
java.lang.Object
javax.swing.plaf.ComponentUI
javax.swing.plaf.ListUI
org.jdesktop.swingx.plaf.YListUI
org.jdesktop.swingx.plaf.basic.BasicYListUI
- Direct Known Subclasses:
BasicXListUI
,SynthYListUI
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static class
class
This class should be treated as a "protected" inner class.protected class
class
TheListDataListener
that's added to theJLists
model atinstallUI time
, and whenever the JList.model property changes.class
The ListSelectionListener that's added to the JLists selection model at installUI time, and whenever the JList.selectionModel property changes.class
Mouse input, and focus handling for JList.class
The PropertyChangeListener that's added to the JList at installUI time. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final StringBuilder
protected static final int
Used by IncrementLeadSelectionAction.protected static final int
Used by IncrementLeadSelectionAction.protected static final TransferHandler
protected static final int
protected static final int
Used by IncrementLeadSelectionAction.protected BasicYListUI.Handler
Fields inherited from class org.jdesktop.swingx.plaf.YListUI
cellHeight, cellHeights, cellRendererChanged, cellWidth, columnCount, componentOrientationChanged, fixedCellHeightChanged, fixedCellWidthChanged, focusListener, fontChanged, heightChanged, isFileList, isLeftToRight, layoutOrientation, layoutOrientationChanged, list, listDataListener, listHeight, listSelectionListener, listWidth, modelChanged, mouseInputListener, preferredHeight, propertyChangeListener, prototypeCellValueChanged, rendererPane, rowsPerColumn, selectionModelChanged, timeFactor, updateLayoutStateNeeded, widthChanged
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void
checkBaselinePrecondition
(JComponent c, int width, int height) Fix for Issue #1495: NPE on getBaseline.protected FocusListener
protected ListDataListener
Creates an instance ofListDataListener
that's added to theJLists
by model as needed.protected ListSelectionListener
Creates an instance ofListSelectionHandler
that's added to theJLists
by selectionModel as needed.protected MouseInputListener
Creates a delegate that implementsMouseInputListener
.protected PropertyChangeListener
Creates an instance ofPropertyChangeHandler
that's added to theJList
byinstallUI()
.static ComponentUI
int
getBaseline
(JComponent c, int width, int height) protected Rectangle
getCellBounds
(JList<?> list, int index) Gets the bounds of the specified model index, returning the resulting bounds, or null ifindex
is not valid.protected Rectangle
protected BasicYListUI.Handler
protected void
this method is called at installUI() time.protected void
this method is called at installUI() time.protected void
this method is called at installUI() time.void
static void
void
paint
(Graphics g, JComponent c) protected void
paintCell
(Graphics g, int row, Rectangle rowBounds, ListCellRenderer<Object> cellRenderer, ListModel<Object> dataModel, ListSelectionModel selModel, int leadIndex) Paint one List cell: compute the relevant state, get the "rubber stamp" cell renderer component, and then use theCellRendererPane
to paint it.protected void
protected void
paintImpl
(Graphics g, JComponent c) protected void
protected void
Select the next row and force it to be visible.protected void
Select the previous row and force it to be visible.protected void
protected void
protected void
void
protected void
Methods inherited from class org.jdesktop.swingx.plaf.YListUI
convertLocationToColumn, convertLocationToRow, convertModelToColumn, convertModelToRow, convertRowToY, convertYToRow, getCellBounds, getElementCount, getHeight, getModelIndex, getRowCount, getViewModel, indexToLocation, locationToIndex, maybeUpdateLayoutState, updateLayoutState
Methods inherited from class javax.swing.plaf.ComponentUI
contains, getAccessibleChild, getAccessibleChildrenCount, getMaximumSize, getMinimumSize, update
-
Field Details
-
handler
-
DROP_LINE_THICKNESS
protected static final int DROP_LINE_THICKNESS- See Also:
-
BASELINE_COMPONENT_KEY
-
CHANGE_LEAD
protected static final int CHANGE_LEADUsed by IncrementLeadSelectionAction. Indicates the action should change the lead, and not select it.- See Also:
-
CHANGE_SELECTION
protected static final int CHANGE_SELECTIONUsed by IncrementLeadSelectionAction. Indicates the action should change the selection and lead.- See Also:
-
EXTEND_SELECTION
protected static final int EXTEND_SELECTIONUsed by IncrementLeadSelectionAction. Indicates the action should extend the selection from the anchor to the next index.- See Also:
-
defaultTransferHandler
-
-
Constructor Details
-
BasicYListUI
-
-
Method Details
-
createUI
-
loadActionMap
-
paintCell
protected void paintCell(Graphics g, int row, Rectangle rowBounds, ListCellRenderer<Object> cellRenderer, ListModel<Object> dataModel, ListSelectionModel selModel, int leadIndex) Paint one List cell: compute the relevant state, get the "rubber stamp" cell renderer component, and then use theCellRendererPane
to paint it. Subclasses may want to override this method rather thanpaint()
.- Parameters:
g
- an instance ofGraphics
row
- a rowrowBounds
- a bounding rectangle to render tocellRenderer
- a list ofListCellRenderer
dataModel
- a list modelselModel
- a selection modelleadIndex
- a lead index- See Also:
-
paint
copied from javax.swing.plaf.basic.BasicListUI to call paintImpl
- Overrides:
paint
in classComponentUI
-
paintImpl
-
paintDropLine
-
getDropLineRect
-
getBaseline
- Overrides:
getBaseline
in classComponentUI
-
checkBaselinePrecondition
Fix for Issue #1495: NPE on getBaseline. As per contract, that methods needs to throw Exceptions on illegal parameters. As we by-pass super, need to do the check and throw ouerselves.- Parameters:
c
- JComponentwidth
- expected ≥ 0height
- expected ≥ 0- Throws:
IllegalArgumentException
- if width or height < 0NullPointerException
- if c == null
-
getBaselineResizeBehavior
- Overrides:
getBaselineResizeBehavior
in classComponentUI
-
getPreferredSize
The preferredSize of the list depends upon the layout orientation. Threre are 3 layouts
VERTICAL
,HORIZONTAL_WRAP
, andVERTICAL_WRAP
- Overrides:
getPreferredSize
in classComponentUI
- See Also:
-
selectPreviousIndex
protected void selectPreviousIndex()Select the previous row and force it to be visible.- See Also:
-
selectNextIndex
protected void selectNextIndex()Select the next row and force it to be visible.- See Also:
-
installKeyboardActions
protected void installKeyboardActions()this method is called at installUI() time.- Overrides:
installKeyboardActions
in classYListUI
- See Also:
-
uninstallKeyboardActions
protected void uninstallKeyboardActions() -
installListeners
protected void installListeners()this method is called at installUI() time.- Overrides:
installListeners
in classYListUI
- See Also:
-
uninstallListeners
protected void uninstallListeners() -
installDefaults
protected void installDefaults()this method is called at installUI() time.- Overrides:
installDefaults
in classYListUI
- See Also:
-
updateIsFileList
protected void updateIsFileList() -
uninstallDefaults
protected void uninstallDefaults() -
installUI
Initializes
super.list
withJComponent c
by calling protected void installDefaults() protected void installListeners() protected void installKeyboardActions()Initializes
super.list
withJComponent c
by calling protected void installDefaults() protected void installListeners() protected void installKeyboardActions() -
uninstallUI
- Overrides:
uninstallUI
in classComponentUI
-
getCellBounds
Gets the bounds of the specified model index, returning the resulting bounds, or null ifindex
is not valid.with LOG
- Overrides:
getCellBounds
in classYListUI
- Parameters:
list
- JListindex
- int- Returns:
- Rectangle
-
getHandler
-
createMouseInputListener
Creates a delegate that implementsMouseInputListener
. The delegate is added to the correspondingjava.awt.Component
listener lists atinstallUI()
time. Subclasses can override this method to return a customMouseInputListener
, 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); } } }
- Returns:
- an instance of
MouseInputListener
- See Also:
-
createFocusListener
-
createListSelectionListener
Creates an instance ofListSelectionHandler
that's added to theJLists
by selectionModel as needed. Subclasses can override this method to return a customListSelectionListener
, 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); } } }
- Returns:
- an instance of
ListSelectionHandler
- See Also:
-
redrawList
protected void redrawList() -
createListDataListener
Creates an instance ofListDataListener
that's added to theJLists
by model as needed. Subclasses can override this method to return a customListDataListener
, 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); } } }
- Returns:
- an instance of
ListDataListener
- See Also:
-
createPropertyChangeListener
Creates an instance ofPropertyChangeHandler
that's added to theJList
byinstallUI()
. Subclasses can override this method to return a customPropertyChangeListener
, 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); } } }
- Returns:
- an instance of
PropertyChangeHandler
- See Also:
-