import java.awt.BorderLayout;
import java.awt.Container;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JList;
import javax.swing.JScrollPane;
public class DualSample {
public static void main(String args[]) {
String labels[] = { "A", "B", "C", "D","E", "F", "G", "H","I", "J" };
JFrame f = new JFrame("Sample Components");
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JList list = new JList(labels);
JScrollPane scrollPane = new JScrollPane(list);
JComboBox comboBox = new JComboBox(labels);
comboBox.setMaximumRowCount(4);
Container contentPane = f.getContentPane();
contentPane.add(comboBox, BorderLayout.NORTH);
contentPane.add(scrollPane, BorderLayout.CENTER);
f.setSize(300, 200);
f.setVisible(true);
}
}
|