JList Class
Package: javax.swing
Using this creates a list component, which displays lists of objects within a box. Depending on how the list is configured, the user can be allowed to select one item in the list or multiple items. In addition, you have amazing control of how the items in the list are displayed.
Figure 5-8 shows a list component.

Figure 5-8
Constructors
|
Constructor |
Description |
|
|
Creates an empty list |
|
|
Creates a list that uses the specified list model |
|
|
Creates a list and fills it with the values in the array |
|
|
Creates a list and fills it with the values in the vector |
|
|
Clears all selections |
Methods
|
Method |
Description |
|
|
Returns the index of the first selected item, or |
|
|
Returns an array with the index of each selected item. The array is empty if no items are selected. |
|
|
Returns the first selected item or |
|
|
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