• Post Reply Bookmark Topic Watch Topic
  • New Topic

getSelectedIndex  RSS feed

 
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: 53779
128
  • 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
Posts: 20898
81
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
Boost this thread!