June 2017
Beginner
1296 pages
69h 23m
English
... selected values in copyJList
42 copyJList.setListData(
43 colorJList.getSelectedValuesList().toArray(
44 new String[0]));
45 }
46 }
47 );
48
49 add(copyJButton); // add copy button to JFrame
50
51 copyJList = new JList<String>(); // list to hold copied color names
52 copyJList.setVisibleRowCount(5); // show 5 rows
53 copyJList.setFixedCellWidth(100); // set width
54 copyJList.setFixedCellHeight(15); // set height
55 copyJList.setSelectionMode(
56 ListSelectionModel.SINGLE_INTERVAL_SELECTION);
57 add(new JScrollPane(copyJList)); // add list with scrollpane
58 }
59 }
MultipleSelectionFrame.
1 // Fig. 26.26: MultipleSelectionTest.java
2 // Testing MultipleSelectionFrame.
3 import javax.swing.JFrame;
4
5 public class MultipleSelectionTest ...Read now
Unlock full access