I want to fill all the fields when I click on a table row. If I click a row in table it fills all the JTextField
& JComboBox
components, but not the JDateChooser
.
How could I fill date chooser field when I select a row in table?
This is the code:
private void jTable1MouseClicked(java.awt.event.MouseEvent evt) {
int SelectedRowIndex=jTable1.getSelectedRow();
jComboBox2.addItem((String)jTable1.getValueAt(SelectedRowIndex, 0));
jComboBox2.setSelectedItem((String)jTable1.getValueAt(SelectedRowIndex, 0));
jComboBox3.addItem((String)jTable1.getValueAt(SelectedRowIndex, 1));
jComboBox3.setSelectedItem((String)jTable1.getValueAt(SelectedRowIndex, 1));
jTextField2.setText((String)jTable1.getValueAt(SelectedRowIndex, 2));
jComboBox5.addItem((String)jTable1.getValueAt(SelectedRowIndex, 3));
jComboBox5.setSelectedItem((String)jTable1.getValueAt(SelectedRowIndex, 3));
jComboBox6.addItem((String)jTable1.getValueAt(SelectedRowIndex, 4));
jComboBox6.setSelectedItem((String)jTable1.getValueAt(SelectedRowIndex, 4));
jTextField6.setText((String)jTable1.getValueAt(SelectedRowIndex, 5));
jComboBox14.addItem((String)jTable1.getValueAt(SelectedRowIndex, 6));
jComboBox14.setSelectedItem((String)jTable1.getValueAt(SelectedRowIndex, 6));
jTextField5.setText((String)jTable1.getValueAt(SelectedRowIndex, 7));
jComboBox13.addItem((String)jTable1.getValueAt(SelectedRowIndex, 8));
jComboBox13.setSelectedItem((String)jTable1.getValueAt(SelectedRowIndex, 8));
jComboBox4.addItem((String)jTable1.getValueAt(SelectedRowIndex, 9));
jComboBox4.setSelectedItem((String)jTable1.getValueAt(SelectedRowIndex, 9));
jTextField3.setText((String)jTable1.getValueAt(SelectedRowIndex, 10));
java.sql.Date date1 = new java.sql.Date(jDateChooser2.getDate().getTime());
date1.setDate((int)jTable1.getValueAt(SelectedRowIndex, 11));
}