The moose likes Beginning Java and the fly likes getSelectedIndex Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Reply 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: 32712
    
    4
Read the API documentation for JComboBox#getSelectedIndex. You are using incorrect arguments.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19216

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


SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: getSelectedIndex
 
Similar Threads
Head First Design Patterns Release Date
WA #1.....word association
about dataBase books
How can I get sysdate in java?
Another format check :P