get combobox selected text?
i have this code to display the description of rank from the list in combobox. i get to know what is select in the combo box thru it index.
private void cmborankActionPerformed(java.awt.event.ActionEvent evt) {
switch(cmborank.getSelectedIndex()){
case 0:
txtrank.setText("DIRECTOR");
break;
case 1:
txtrank.setText("CHIEF SUPERINTENDENT");
break;
case 2:
txtrank.setText("SENIOR SUPERINTENDENT");
break;
case 3:
txtrank.setText("SUPERINTENDENT");
break;
case 4:
txtrank.setText("CHIEF INSPECTOR");
break;
case 5:
txtrank.setText("SENIOR INSPECTOR");
break;
case 6:
txtrank.setText("INSPECTOR");
break;
case 7:
txtrank.setText("SENIOR JAIL OFFICER IV");
break;
case 8:
txtrank.setText("SENIOR JAIL OFFICER III");
break;
case 9:
txtrank.setText("SENIOR JAIL OFFICER II");
break;
case 10:
txtrank.setText("SENIOR JAIL OFFICER I");
break;
case 11:
txtrank.setText("JAIL OFFICER III");
break;
case 12:
txtrank.setText("JAIL OFFICER II");
break;
case 13:
txtrank.setText("JAIL OFFICER I");
break;
case 14:
txtrank.setText("CIVILIAN EMPLOYEE");
break;
}
}
... is there a way to know or get the selected text from the combobox not using the indexing instead use the text?
like for example if the text in combobox is "DIR" then the text in my textfield will be "DIRECTOR".
in VB6 i use if(combobox.text="DIR") then... is there a similar way in java like this?
thank you for helping...
God Bless...
killuasoft

