0

Hello, I want this Switch Methods to create newfucntion by itself, then just call the fucntion of this Switch to use, Please How

int grade = Integer.parseInt(model.getValueAt(i, 3).toString()); switch (grade) { case 1: cbxGrade.setSelectedIndex(0); break; case 2: cbxGrade.setSelectedIndex(1); break; case 3: cbxGrade.setSelectedIndex(2); break; case 4: cbxGrade.setSelectedIndex(3); break; case 5: cbxGrade.setSelectedIndex(4); break; case 6: cbxGrade.setSelectedIndex(5); break; case 7: cbxGrade.setSelectedIndex(6); break; case 8: cbxGrade.setSelectedIndex(7); break; case 9: cbxGrade.setSelectedIndex(8); break; case 10: cbxGrade.setSelectedIndex(9); break; case 11: cbxGrade.setSelectedIndex(10); break; case 12:

20th May 2022, 4:53 PM
Samnang Choeurn
Samnang Choeurn - avatar
2 Respuestas
+ 3
First of all. Do int grade = Integer.parseInt(model.getValueAt(i, 3).toString()); cbxGrade.setSelectedIndex(grade-1); If you want a upper and lower bound. Then use a if statement. if (grade>0 && grade<13) { //above code } What do you mean by "create class"?
20th May 2022, 5:01 PM
Mustafa A
Mustafa A - avatar