• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

HELP with JComboBox

 
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 1492
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!!!
 
Blueberry pie is best when it is firm and you can hold in your hand. Smell it. And smell this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic