This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes getSelectedIndex Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Bookmark "getSelectedIndex" Watch "getSelectedIndex" New topic
Author

getSelectedIndex

nitish dhar
Greenhorn

Joined: Aug 19, 2007
Posts: 11
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

Joined: Oct 13, 2005
Posts: 43885
    
  32
Read the API documentation for JComboBox#getSelectedIndex. You are using incorrect arguments.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 20077
    
  30

Days of the month / year are 1 based, whereas the JComboBox index is 0 based.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: getSelectedIndex
 
It's not a secret anymore!