arrays - Trying to reset values of Comboboxes using a loop (GUI/Java) -


i'm using netbeans make gpa calculator uses series of combo boxes (5, same). i'm trying reset values first value after calculator runs using loop:

javax.swing.jcombobox aocomboboxes []=new javax.swing.jcombobox [6];      aocomboboxes [0]= cmbxacc200;     aocomboboxes [1]= cmbxbusm241;     aocomboboxes [2]= cmbxfin201;     aocomboboxes [3]= cmbxis110;     aocomboboxes [4]=cmbxis201;     aocomboboxes[5]=cmbxis303;      (int i=0; i<aocomboboxes.length; i++)      {         aocomboboxes[0].setselectedindex(0);     } 

is possible? right now, code doesn't function , i'm not sure if because of error in way i've written code, or if isn't possible this. i'm more curious whether possible because i'll want run loop data each combo box , assign variable: int ilettergrade;

for (int i=0; i<aocomboboxes.length; i++)  {   ilettergrade=aocomboboxes[0].getselectedindex();       } 

well 1st loop reset aocomboboxes[0] 6 times because have hard coded index 0.while retrieving data did same mistake in 2nd loop.

just replace loops below:

 (int i=0; i<aocomboboxes.length; i++)  {     aocomboboxes[i].setselectedindex(0); } 

2nd loop:

 (int i=0; i<aocomboboxes.length; i++)   {     ilettergrade=aocomboboxes[i].getselectedindex();        } 

Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -

java - Digest auth with Spring Security using javaconfig -