Skip to main content

Jtable sorting of integer values

Please note these forums are being decommissioned and use the new and improved forums at
No replies
Joined: 2012-11-15

// I want to sort to the jtable by Integer value for 0. column.
// I need to override "getColumnClass" method.
// I overrided "getColumnClass" when define jTable

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"
) {
Class[] types = new Class [] {
java.lang.Integer.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class
boolean[] canEdit = new boolean [] {
false, false, false, false

public Class getColumnClass(int columnIndex) {
return types [columnIndex];

public boolean isCellEditable(int rowIndex, int columnIndex) {
return canEdit [columnIndex];

// but I can not override the "getColumnClass" after I set the model of jtable.