Hi guys,
Have an "AutoSearchComboBox" as follows for searching the combolist fast.Have some problems with the selection in the AutoSearchComboBox.
Iam creating the combo boxes as follows from another source file.
private AutoSearchComboBox indexTagCombo,indexValueCombo
//The following function is called for loading the comboBoxes.
private void loadInitialIndexTagValues()
{
indexTagCombo.removeAllItems();
//Getting values to be fiiled in the comboBox.
Set tags = this.model.getAvailableIndexTags();
// Iterating over the elements in the set
Iterator tagIter = tags.iterator();
while (tagIter.hasNext()) {
indexTagCombo.addItem(tagIter.next());
}
//Loading index values.
String currTag = (String)indexTagCombo.getSelectedItem(); //Selection problem 1
The statement above returns me null & the follwing code doesnt fill the other comboBox.
Set values = model.getAllValues(currTag);
indexValueCombo.removeAllItems();
Iterator valIter = values.iterator();
while (valIter.hasNext()) {
indexValueCombo.addItem(valIter.next());
}
}
Have added an "itemListener" to the indexTagCombo as follows:
indexTagCombo.addItemListener(new ItemListener(){
public void itemStateChanged(ItemEvent e)
{
indexTagSelection(e);
}
});
private void indexTagSelection(ItemEvent e) {
if (e.getStateChange() == ItemEvent.SELECTED)
{
//The "getStateChange" is never ItemEvent.SELECTED,so that it never gets in to this loop.//Another problem
//code goes Here
}
}
There is some problem with the defined "AutoSearchComboBox" with selection.When I change the privately defined "AutoSearchComboBox" to JComboBox and make it editable,all the selection problems are gone.
In short all the "getSelectedItem" from the "AutoSearchComboBox" and the "itemstate" events defined are not going to the "ItemEvent.SELECTED"
What should I fix in the "AutoSearchComboBox" so that the selections work.
Any help is greatly appreciated.
Thanks
P