The last component that we will examine is JList. This is Swing’s basic list class. It supports the selection of one or more items from a list. Although often the list consists of strings, it is possible to create a list of just about any object that can be displayed. JList is so widely used in Java that it is highly unlikely that you have not seen one before.
In the past, the items in a JList were represented as Object references. However, with the release of JDK 7, JList was made generic, and it is now declared like this:
Here, E represents the type of the items in the list. As a result, JList is now type-safe.
The discussion and example that follow use the generic version of JList. If your compiler predates ...