Gets the AccessibleContext
associated with this JList
.
For JList
, the AccessibleContext
takes the form of an
AccessibleJList
.
A new AccessibleJList
instance is created if necessary.
AccessibleJList
that serves as the
AccessibleContext
of this JList
Computes the size of viewport needed to display visibleRowCount
rows. The value returned by this method depends on the layout
orientation:
VERTICAL
:
This is trivial if both fixedCellWidth
and fixedCellHeight
have been set (either explicitly or by specifying a prototype cell value).
The width is simply the fixedCellWidth
plus the list's horizontal
insets. The height is the fixedCellHeight
multiplied by the
visibleRowCount
, plus the list's vertical insets.
If either fixedCellWidth
or fixedCellHeight
haven't been
specified, heuristics are used. If the model is empty, the width is
the fixedCellWidth
, if greater than 0
, or a hard-coded
value of 256
. The height is the fixedCellHeight
multiplied
by visibleRowCount
, if fixedCellHeight
is greater than
0
, otherwise it is a hard-coded value of 16
multiplied by
visibleRowCount
.
If the model isn't empty, the width is the preferred size's width,
typically the width of the widest list element. The height is the
fixedCellHeight
multiplied by the visibleRowCount
,
plus the list's vertical insets.
VERTICAL_WRAP
or HORIZONTAL_WRAP
:
This method simply returns the value from getPreferredSize
.
The list's ListUI
is expected to override getPreferredSize
to return an appropriate value.
visibleRowCount
rows
getPreferredScrollableViewportSize, setPrototypeCellValue
Returns the distance to scroll to expose the next or previous block.
For vertical scrolling, the following rules are used:
visibleRect.height
if the list is empty
For horizontal scrolling, when the layout orientation is either
VERTICAL_WRAP
or HORIZONTAL_WRAP
:
visibleRect.width
if the list is empty
For horizontal scrolling and VERTICAL
orientation,
returns visibleRect.width
.
Note that the value of visibleRect
must be the equal to
this.getVisibleRect()
.
visibleRect | the view area visible within the viewport | |
orientation | SwingConstants.HORIZONTAL or
SwingConstants.VERTICAL | |
direction | less or equal to zero to scroll up/back, greater than zero for down/forward |
getScrollableUnitIncrement, Scrollable.getScrollableBlockIncrement
Returns true
if this JList
is displayed in a
JViewport
and the viewport is taller than the list's
preferred height, or if the layout orientation is VERTICAL_WRAP
and visibleRowCount <= 0
; otherwise returns false
.
If false
, then don't track the viewport's height. This allows
vertical scrolling if the JViewport
is itself embedded in a
JScrollPane
.
Returns true
if this JList
is displayed in a
JViewport
and the viewport is wider than the list's
preferred width, or if the layout orientation is HORIZONTAL_WRAP
and visibleRowCount <= 0
; otherwise returns false
.
If false
, then don't track the viewport's width. This allows
horizontal scrolling if the JViewport
is itself embedded in a
JScrollPane
.
Returns the distance to scroll to expose the next or previous row (for vertical scrolling) or column (for horizontal scrolling).
For horizontal scrolling, if the layout orientation is VERTICAL
,
then the list's font size is returned (or 1
if the font is
null
).
visibleRect | the view area visible within the viewport | |
orientation | SwingConstants.HORIZONTAL or
SwingConstants.VERTICAL | |
direction | less or equal to zero to scroll up/back, greater than zero for down/forward |
getScrollableBlockIncrement, Scrollable.getScrollableUnitIncrement
Returns the tooltip text to be used for the given event. This overrides
JComponent
's getToolTipText
to first check the cell
renderer component for the cell over which the event occurred, returning
its tooltip text, if any. This implementation allows you to specify
tooltip text on the cell level, by using setToolTipText
on your
cell renderer component.
Note: For JList
to properly display the
tooltips of its renderers in this manner, JList
must be a
registered component with the ToolTipManager
. This registration
is done automatically in the constructor. However, if at a later point
JList
is unregistered, by way of a call to
setToolTipText(null)
, tips from the renderers will no longer display.
event | the MouseEvent to fetch the tooltip text for |
JComponent.setToolTipText, JComponent.getToolTipText
Returns "ListUI"
, the UIDefaults
key used to look
up the name of the javax.swing.plaf.ListUI
class that defines
the look and feel for this component.
JComponent.getUIClassID, UIDefaults.getUI
Returns a String
representation of this JList
.
This method is intended to be used only for debugging purposes,
and the content and format of the returned String
may vary
between implementations. The returned String
may be empty,
but may not be null
.
String
representation of this JList
.
Resets the ListUI
property by setting it to the value provided
by the current look and feel. If the current cell renderer was installed
by the developer (rather than the look and feel itself), this also causes
the cell renderer and its children to be updated, by calling
SwingUtilities.updateComponentTreeUI
on it.
UIManager.getUI, SwingUtilities.updateComponentTreeUI
Diagram: JList, JComboBox