private void EditeActionPerformed(java.awt.event.ActionEvent evt)
{
// TODO add your handling code here:
String btntitle=this.Edite.getText();
if(btntitle.compareToIgnoreCase("edite")==0) {
int index=this.Table.getSelectedRow();
this.txtProductId.setText(""+tm.getValueAt(index, 0));
this.txtLastName.setText(""+tm.getValueAt(index, 1));
this.txtFirstName.setText(""+tm.getValueAt(index, 2));
this.txtTel.setText(""+tm.getValueAt(index, 3));
this.jComboBoxGender.setSelectedIndex(tm.getValueAt(index, 4));
this.Edite.setText("update");
}
if(btntitle.compareToIgnoreCase("update")==0) {
int index=Table.getSelectedRow();
int productid=Integer.parseInt(txtProductId.getText());
String lastname=txtLastName.getText();
String firstname=txtFirstName.getText();
String sex=txtTel.getText();
tm.setValueAt(productid,index, 0);
tm.setValueAt(lastname,index, 1);
tm.setValueAt(firstname,index, 2);
tm.setValueAt(sex,index, 3);
cleardata();
}
}
你能更好地格式化你的答案,給你做了什麼解釋? –