"main program" method - construct and show
String[] filters = {
"Apples",
"Bananas",
"Run for it!"
};
int DEFAULT_FILTER = 1; // i.e., filters[DEFAULT_FILTER] is default
// create a this object, tell it to show up
final JFrame f = new JFrame("FilterGUI Demo 1");
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
final FilterGUI comp = new FilterGUI(filters, DEFAULT_FILTER);
Container cp = f.getContentPane();
cp.add(BorderLayout.CENTER, comp);
JButton b = new JButton("Show");
cp.add(BorderLayout.SOUTH, b);
b.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
java.util.List l = comp.getSelected();
Iterator it = l.iterator();
while (it.hasNext()) {
System.out.println(it.next());
}
}
});
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.pack();
f.setLocation(200, 200);
f.setVisible(true);