0

I'm a kind of new in Java programming, and today I faced a problem.

What the problematic part of the program should do is essentially described by the following steps:

  1. Do a query
  2. Fill a jTable with the result of the query
  3. Apply a rowsorter to the jtable
  4. Make the cells of the jTable not editable but clickable

I've found a solution on the Internet, but I don't really know how to implement it.

The solution should be, if I didn't misunderstand, overriding the isCellEditable method of the DefaultTableModel associated to the table so it will always return false.

This is the code that does the steps above described:

ResultSet rs = CheckList.dbConnection.genericQuery(query);
if (rs != null) {
    jTable1.setRowSorter(null);                                             \\STEP 1
    jTable1.setModel(resultSetToTableModel(rs));                            \\STEP 2
    DefaultTableModel model = (DefaultTableModel) jTable1.getModel();       \\STEP 3
    TableRowSorter <DefaultTableModel> sorter = new TableRowSorter(model);  \\STEP 3
    jTable1.setRowSorter(sorter);                                           \\STEP 3
}

With this said, how can I implement the overriding of the method? Obviously if you find something wrong in the code, feel free to fix it, I'm here to learn! :P

Vincenzo

StepUp
  • 36,391
  • 15
  • 88
  • 148

0 Answers0