CS 121 Lecture Notes - Lecture 74: Display List

44 views2 pages
JList:
The ListPanel class defines the panel that contains the list of file names.
We use a list component, defined by the JList class, to display list of file
names.
o List contents are set up as an array of String objects.
They are passed into the JList constructor.
All of the options in a JList component are visible.
o When user selects an item using the mouse, it is highlighted.
o When a new item is selected, previously selected item is automatically
unhighlighted.
The contents of a JList can be specified using an array of objects passed
into the constructor.
o Methods of JList class are used to manage list in various ways,
including retrieving currently selected item.
Similarities & Differences Between Combo & JList Object:
o Allow user to select an item from a set of choices.
o Choices on a list are always displayed w/ current choice highlighted.
o Whereas a combo box presents its options only when user presses it w/
the mouse.
The only item displayed all the time in a combo box is the current selection.
o JList object generates a list selection event whenever current selection
of the list changes.
o The ListSelectionListener interface contains 1 method called
valueChanged.
In this program, private inner class called ListListener defines
listener for the list of file names.
find more resources at oneclass.com
find more resources at oneclass.com
Unlock document

This preview shows half of the first page of the document.
Unlock all 2 pages and 3 million more documents.

Already have an account? Log in

Document Summary

The listpanel class defines the panel that contains the list of file names. We use a list component, defined by the jlist class, to display list of file names: list contents are set up as an array of string objects, they are passed into the jlist constructor. All of the options in a jlist component are visible: when user selects an item using the mouse, it is highlighted, when a new item is selected, previously selected item is automatically unhighlighted. The contents of a jlist can be specified using an array of objects passed into the constructor: methods of jlist class are used to manage list in various ways, including retrieving currently selected item. The only item displayed all the time in a combo box is the current selection: jlist object generates a list selection event whenever current selection of the list changes, the listselectionlistener interface contains 1 method called valuechanged.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents