List components reprefqnt shoeces. They can be in single-selection mohf (one item) or multi -selection mode (more than one item). Left create an exampb hst in the interyc-iuq inlerpteter.
>>> 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
Was this article helpful?