Results 1 to 2 of 2
  1. #1
    aslanali555 is offline Member
    Join Date
    Nov 2012
    Posts
    3
    Rep Power
    0

    Default Jtable Row Sorter as Integer Value

    I want to sort to the jtable by Integer value for 0. column.
    I need to override "getColumnClass" method.
    I overrided "getColumnClass" when define "tableMalzeme"
    Java Code:
    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];
    }
    });
    tableMalzeme.setAutoCreateRowSorter(true);
    but I can not override the "getColumnClass" after I set the model of jtable.

    Java Code:
    tableMalzeme.setModel(DbUtils.resultSetToTableModel(resultSet));

  2. #2
    camickr is offline Senior Member
    Join Date
    Jul 2009
    Posts
    1,236
    Rep Power
    7

Similar Threads

  1. Integer Comparison, Outputting Largest Integer Not Working
    By killingthemonkey in forum New To Java
    Replies: 4
    Last Post: 10-16-2011, 09:59 PM
  2. Replies: 2
    Last Post: 04-10-2009, 12:59 AM
  3. Getting integer values from a JTable
    By zikojam in forum New To Java
    Replies: 1
    Last Post: 12-11-2008, 03:06 PM
  4. how to use sorter on JTable
    By sunilpatel28 in forum Advanced Java
    Replies: 1
    Last Post: 12-10-2008, 12:18 AM
  5. how to use sorter on JTable
    By sunilpatel28 in forum Advanced Java
    Replies: 0
    Last Post: 12-09-2008, 09:24 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •