Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

combo box issues

 
Rich Charlton
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I have written a program with three combo boxes asking user to pick a date. I have one combo for day, one for month and one for year. My problem is that i have designed a for loop to make the numbers 1 to 31 appear in the combo box, although when you run the program you get a blank space where the number 1 should be. Is their way of setting the combo box so that one is shown first, instead of a blank box.

Program:

Any ideas ?

Thanks
 
Don Kiddick
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
setSelectedIndex(0)
 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No More Java Please

Welcome to Javaranch! We don't have too many rules around here but we do have a Naming Policy. Please read and adjust your display name to comform. You can change your display name here.

Thanks.
 
Rich Charlton
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Thanks for taking a look, ive changed my name now hope thats cool.

As for the answer to my question..where do i put the setselectedindex(0);

Do you have any more clarification...

Thanks
 
Don Kiddick
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
it's a method on JComboBox. Look it up in the javadocs
 
Rich Charlton
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I looked it up and got it working. Never new about that specific method for JComboBox.

Many Thanks.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic