Determinate TableColumn's data type

51 views Asked by At

For example I have this random table:
enter image description here

How can I determinate the data type of each column:
First column contains data with String type.
Second column contains data with Double type
Third column contains data with String type.

1

There are 1 answers

2
Pavan Kumar K On BEST ANSWER

Try below...

    //creating a table
    MyTableModel mod = new MyTableModel(data, columnNames);
    JTable table = new JTable(mod);
    table.setVisible(true);
    table.getColumnClass(1); // will return the data type class of first column
    table.isCellEditable(1, 0);