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

Get Java™ How To Program (Early Objects), Tenth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.