In this tutorial you will be able to place the data into textfield, radio buttons, checkbox, combobox when the data in jtable is clicked.
Please watch the video because there are some task to be done beside code
Code to Display Selected Row Values From JTable Into JTextfields, radiobuttons, checkbox in Java
private void jTable_Display_UserMouseClicked(java.awt.event.MouseEvent evt) {// TODO add your handling code here:
int i = jTable_Display_User.getSelectedRow();
TableModel model =jTable_Display_User.getModel();
name.setText(model.getValueAt(i,1).toString());
address.setText(model.getValueAt(i,2).toString());
String sex = model.getValueAt(i,3).toString();
if(sex.equals("Male")){
male.setSelected(true);
}
else{
female.setSelected(true);
}
String knowledge=model.getValueAt(i,4).toString();
switch(knowledge){
case "Java ":
coreJava.setSelected(true);
python.setSelected(false);
break;
case "Python ":
python.setSelected(true);
coreJava.setSelected(false);
break;
default:
coreJava.setSelected(true);
python.setSelected(true);
break;
}
String subject1 = model.getValueAt(i,5).toString();
switch(subject1){
case "Computer Science":
subject.setSelectedIndex(0);
break;
case "Management":
subject.setSelectedIndex(1);
break;
case "Humanities":
subject.setSelectedIndex(2);
break;
case "Arts":
subject.setSelectedIndex(3);
break;
case "Education":
subject.setSelectedIndex(4);
break;
}
}
Please don't forget To Like, Share and Subscribe my Youtube video and Channel.
Youtube Channel Subscription Click Here
No comments:
Post a Comment