June 2002
Beginner to intermediate
640 pages
14h 24m
English
List components represent choices. They can be in single-selection mode (one item) or multi-selection mode (more than one item). Let's create an example list in the interactive interpreter.
>>> from javax.swing import JList >>> list_items = ["Bruce", "Darrell", "Tony", "Debbie", "Karen"] >>> list = JList(list_items)
Here's the interactive session to create a frame:
>>> from javax.swing import JFrame
>>> frame = JFrame("JList example")
>>> frame.contentPane.add(list)
>>> frame.pack()
>>> frame.visible=1
Now we want to do something with our list—that is, handle the list events—so we need to inspect JList's event properties (or look them up in the Java API documentation).
Here's the interactive session to inspect the ...
Read now
Unlock full access