public RadioButtons() { rb1.addActionListener(al); rb2.addActionListener(al); rb3.addActionListener(al); g.add(rb1); g.add(rb2); g.add(rb3); t.setEditable(false); setLayout(new FlowLayout()); add(t); add(rb1); add(rb2); add(rb3); }
public ComboBoxes() { for (int i = 0; i < 4; i++) c.addItem(description[count++]); t.setEditable(false); b.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { if (count < description.length) c.addItem(description[count++]); } }); c.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { t.setText( "index: " + c.getSelectedIndex() + " " + ((JComboBox) e.getSource()).getSelectedItem()); } }); setLayout(new FlowLayout()); add(t); add(c); add(b); }