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

HELP with JComboBox  RSS feed

 
Dave Donohoe
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I have a JComboBox with a list of years from 1900 to 2100.
I want to set the selected item to this year.
I can do this so that the date you see is 2001 BUT when you click on the Comnbo Box the first time, the highlighted year in the list is the first one, so you have to scroll all the way from 1900 to 2001. When you click on the combo a second time, it hightlights the proper year !
I have tried seting the selectedIndex & setting the selectedItem & I have both problems. The Combo is populated from a Vector. I tried using a String array to no avail as well.....
Hope someone can help !!!
Thanks,
D
 
Manfred Leonhardt
Ranch Hand
Posts: 1492
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Dave,
Not sure what you are doing, but the following code works in JDK1.2. The year 2001 is highlighted and the first visible element in the list when it pops up the first time. The demo shows String and vector forms with no difference.

Enjoy,
Manfred.
 
Dave Donohoe
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your reply Manfred....
The code you posted is almost the exact same as mine.
Basically when there is a lot of items in the list, the problem occurs. If I reduc the number in the list, the problem goes away.....
I am at a loss!!!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!