This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

getSelectedIndex

 
nitish dhar
Greenhorn
Posts: 11
  • 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
Posts: 48406
56
  • 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: 20495
54
Chrome Eclipse IDE Java Windows
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic