/* CMPUT114(2003-2004, Fall) http://www-csfy.cs.ualberta.ca/~c114/F03 */ import java.awt.*; import javax.swing.*; import java.applet.*; public class JListPanel extends JApplet { public void init() { this.getContentPane().add(this.getPanel()); } private JList getList() { // Create a List with the 5 course items String[] data = {"Math 113", "Cmput 114", "Phil 120", "Cmput 272", "Chem 105"}; JList tempList = new JList(data); tempList.setVisibleRowCount(2); // Enable single selection tempList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); return tempList; } private JPanel getPanel() { // set layout to GridLayout 2 rows and 2 columns JPanel panel = new JPanel(new GridLayout(2,2,0,0)); JScrollPane spane1 = new JScrollPane(this.getList()); JScrollPane spane2 = new JScrollPane(this.getList()); panel.add(new JLabel("List 1")); panel.add(new JLabel("Same List 2")); panel.add(spane1); panel.add(spane2); return panel; } }