Win a copy of Soft Skills: The software developer's life manual this week in the Jobs Discussion forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

getSelectedIndex

 
nitish dhar
Greenhorn
Posts: 11
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Calendar cal = new GregorianCalendar();
int date=cal.get(Calendar.DATE);


i passed date into the

jComboBox.getSelectedIndex(date)

so that it shows the current date only in the combo box as the first item

but the command seems to have an error ....???
 
Campbell Ritchie
Sheriff
Pie
Posts: 47216
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Read the API documentation for JComboBox#getSelectedIndex. You are using incorrect arguments.
 
Rob Spoor
Sheriff
Pie
Posts: 20368
43
Chrome Eclipse IDE Java Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Days of the month / year are 1 based, whereas the JComboBox index is 0 based.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic