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 |
|
Get Java For Dummies Quick Reference 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.