Skip to Main Content
Java
book

Java

by Michael Sikora
January 2003
Beginner to intermediate content levelBeginner to intermediate
150 pages
7h 28m
English
Morgan Kaufmann
Content preview from Java
II 8.3 Component Methods
! 1 5
Then create the list model object using the javax.swing.DefaultListModel constructor, as
follows:
shoppingListModel = new DefaultListModel() ;
Individual list elements are added to the model using the javax.swing.DefaultList-
Model. addElement method. For example,
shoppingListModel, addElement ("ice axe") ;
The list object itself is created using the javax, swing. JList constructor, as follows:
shoppingList = new JList (shoppingListModel) ;
Note the constructor requires the list model as an argument.
To specify that only one item can be selected from the list at any one time, use the
setSelectionMode ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Java Programming

Java Programming

Poornachandra Sarang
JAVA Programming

JAVA Programming

K. Rajkumar
Java Programming

Java Programming

Hari Mohan Pandey
Java 9 for Programmers

Java 9 for Programmers

Paul J. Deitel, Harvey Deitel

Publisher Resources

ISBN: 9781558609099