Cover Page by Gary Cornell, Cay S. Horstmann

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

O'Reilly logo

6.1.2. List Models

In the preceding section, you saw the most common method for using a list component:

1. Specify a fixed set of strings for display in the list.

2. Place the list inside a scroll pane.

3. Trap the list selection events.

In the remainder of the section on lists, we cover more complex situations that require a bit more finesse:

• Very long lists

• Lists with changing contents

• Lists that don’t contain strings

In the first example, we constructed a JList component that held a fixed collection of strings. However, the collection of choices in a list box is not always fixed. How do we add or remove items in the list box? Somewhat surprisingly, there are no methods in the JList class to achieve this. Instead, you have to understand ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required