Section 12.12 JList
• A JList displays a series of items from which the user may select one or more items. Class JList supports single-selection lists (p. 508) and multiple-selection lists.
• When the user clicks an item in a JList, a ListSelectionEvent (p. 508) occurs. JList method addListSelectionListener (p. 510) registers a ListSelectionListener (p. 510) for a JList’s selection events. A ListSelectionListener of package javax.swing.event(p. 492) must implement method valueChanged.
• JList method setVisibleRowCount (p. 510) specifies the number of visible items in the list.
• JList method setSelectionMode (p. 510) specifies a list’s selection mode.
• A JList can be attached to a JScrollPane (p. 510) to provide a scrollbar for the JList
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