Reputation: 3
I created jtable in Netbeans.
tableMalzeme.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
{null, null, null, null},
{null, null, null, null},
{null, null, null, null},
{null, null, null, null}
},
new String [] {
"Title 1", "Title 2", "Title 3", "Title 4"
}
) {
boolean[] canEdit = new boolean [] {
false, false, false, false
};
public boolean isCellEditable(int rowIndex, int columnIndex) {
return canEdit [columnIndex];
}
});
I want to sort numerically. Default value of "getColumnClass" is "Object" but I want to change this value. How do you make it?
tableMalzeme.setModel(DbUtils.resultSetToTableModel(resultSet));
tableMalzeme.setAutoCreateRowSorter(true);
tableMalzeme.getColumnClass(0).cast(Integer.class);
Upvotes: 0
Views: 730
Reputation: 7
Try this code( hope this is what you are looking for):
(Integer)(tableMalzeme.getColumnClass(0));
Upvotes: 0
Reputation: 324108
sorted as a String but I want to sort as a Integer
You need to:
Integer
objects to the TableModel
getColumnClass(...)
class method to return Intgeger.class
for the column that contains integers.Upvotes: 2