eral
eral

Reputation: 3

How to stop mouseClicked?

I have one table where it shows some data from sql server and when I click it it also shows data on text fields that gets it directly from the table. But once I click one row on the table it remains clicked until the frame is closed. How can I disable it? Heres my code on click event.

int rowIndex; 

private void jTable1MouseClicked(java.awt.event.MouseEvent evt) {                                     
        rowIndex = jTable1.getSelectedRow();
     DefaultTableModel model = (DefaultTableModel)jTable1.getModel();
     if(model.getValueAt(rowIndex, 3).toString().equals("Mashkull  "))
     {
        jRadioButton1_mashkull1.setSelected(true);
        jRadioButton2_femer1.setSelected(false);

     } else {
     jRadioButton2_femer1.setSelected(true);
     jRadioButton1_mashkull1.setSelected(false);
     }
     jTextField1_id1.setText(model.getValueAt(rowIndex, 0).toString());
     jTextField1_emri1.setText(model.getValueAt(rowIndex, 1).toString());
     jTextField1_mbiemri2.setText(model.getValueAt(rowIndex, 2).toString());
     jTextField1_nrtel1.setText(model.getValueAt(rowIndex, 5).toString());
     jTextArea1_adresa1.setText(model.getValueAt(rowIndex, 6).toString());

     Date bdate;
    try {
        bdate= new SimpleDateFormat("yyyy-MM-dd").parse(model.getValueAt(rowIndex, 4).toString());
        jDateChooser1_data1.setDate(bdate);
    } catch (ParseException ex) {
        Logger.getLogger(kontrollostudentet.class.getName()).log(Level.SEVERE, null, ex);
    }
}    

Upvotes: 0

Views: 72

Answers (1)

jhamon
jhamon

Reputation: 3691

You can make a call to clearSelection() right after getting the row index.

public void clearSelection()

Deselects all selected columns and rows.

Upvotes: 3

Related Questions