The JList Class
The JList
class is the generic Swing
implementation of a list component. The class works reasonably well
as a drop-in replacement for the AWT
List class. If the selection mode is set
appropriately, you can make multiple selections by clicking with the
mouse while holding down the “Shift” or
“Ctrl” modifier keys. Unlike AWT, the
JList class does not provide scrolling
capabilities; it must be set as the viewport of a
JScrollPane in order to support scrolling. Figure 7.8 shows the JList component
with three separate look-and-feels.

Figure 7-8. The JList component in the three look-and-feels
Properties
The JList class essentially combines the features
of the data model, the selection model, and the cell renderer into a
single Swing component. The properties of the
JList class are shown in Table 7.9.
Table 7-9. JList Properties
|
Property |
Data Type |
get |
is |
set |
bound |
Default |
|---|---|---|---|---|---|---|
| See also properties from JComponent (Table 3.5) | ||||||
|
|
|
• |
• |
• | ||
|
|
|
• |
• |
• |
| |
|
|
|
• |
• |
• |
from L&F | |
|
|
|
• |
| |||
|
|
|
• |
| |||
|
|
|
• | ||||
|
|
|
• |
• |
• |
from L&F | |
|
|
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access