Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

problem with user defined combobox selection  RSS feed

Arun Sanker
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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()

//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()) {


//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);
Iterator valIter = values.iterator();
while (valIter.hasNext()) {


Have added an "itemListener" to the indexTagCombo as follows:
indexTagCombo.addItemListener(new ItemListener(){

public void itemStateChanged(ItemEvent 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.

It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!