Sean Connolly

Greenhorn
+ Follow
since Sep 16, 2010
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Sean Connolly

I just figured this one out a couple weeks ago after not finding a solution online. The problem is in JComboBox's getSelectedIndex method. There's a check there that if the selected value is null, it is hardcoded to return -1 as the index (rather than 0 if it were the first item in your combo box). The UI uses the selected index to return the next value. If it returns -1, there is no next value by its logic so it ignores the down arrow until a "valid" value is selected.

The solution I came up with was to subclass JComboBox (which I had already done) and override that method to check if null is a value in the model. And if so, to use that index. Otherwise, just return -1 as usual. Simple and it worked.

Enjoy,
-Sean
13 years ago