Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Selecting an Item in a JComboBox Component with Multiple Keystrokes  RSS feed

 
Yoo-Jin Lee
Ranch Hand
Posts: 119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I'm trying to put a JComboBox in a table. Once you click on a cell that is rendered as a JComboBox you can select an item with multiple key strokes. It also must work in Java 1.3.
I have an example from http://javaalmanac.com/egs/javax.swing/combobox_CbMultiKey.html?l=find. It works but only if it is not in a JTable.
I've looked at the bug database Sun keeps, and there seems to be a lot of bugs with how the focus works with a JComboBox.
Any help would be appreciated.
-Yoo-Jin

The following is my code that does not have the desired result:
 
VIJAY Yadlapati
Ranch Hand
Posts: 175
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What I found is when you pressed the First character, the editor losses the focus, and the render gets the focus - to display the corresponding selected item in the combo box.
I traced out this thing by keeping S.O.P statements in the selectionForKey() method..
if (curTime - lastKeyTime < 300)
{
pattern += ("" + aKey).toLowerCase();
}
else
{
pattern = ("" + aKey).toLowerCase();
}

System.out.println("pattern : " + pattern);
Every time the pattern is a single character, and no focus on the combobox, it's no longer a combobox - a Label
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!