Guest_imported
New member
- Jan 1, 1970
- 0
Hi,
I instantiated my jcombobox with a comboboxmodel and i get the list of
names in the combo box but nothing happens when i select anyone of
them. But the same thing works when i instantiate the jcombobox with a
string array. everything works fine.
Any idea whats the problem with ComboBoxModel or any way to know the
problem source.
code follows:
ArrayList persons = someDAO.getAllNames();
final PersonListModel plm = new PersonListModel(persons);
final JComboBox personList = new JComboBox(plm);
personList.setEditable(true);
personList.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JComboBox cb = (JComboBox)e.getSource();
String personName = (String)cb.getSelectedItem();
System.out.println("Name = " + personName);
}
});
I instantiated my jcombobox with a comboboxmodel and i get the list of
names in the combo box but nothing happens when i select anyone of
them. But the same thing works when i instantiate the jcombobox with a
string array. everything works fine.
Any idea whats the problem with ComboBoxModel or any way to know the
problem source.
code follows:
ArrayList persons = someDAO.getAllNames();
final PersonListModel plm = new PersonListModel(persons);
final JComboBox personList = new JComboBox(plm);
personList.setEditable(true);
personList.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JComboBox cb = (JComboBox)e.getSource();
String personName = (String)cb.getSelectedItem();
System.out.println("Name = " + personName);
}
});