質問

I have a legacy swing application where the JTable sorting works correctly with Java 1.5 but not with Java 1.6. Could someone provide me hints as to what could be different between the two versions?

The sorting is handled by a mouse click event handler. Here is the snippet of the code.

 public void mouseClicked(MouseEvent e) 
  {
    if ((e.getModifiers() & InputEvent.BUTTON1_MASK) != 0) 
    {
      JTableHeader header = (JTableHeader) e.getSource();
      JTable table = header.getTable();
      int col = table.columnAtPoint(new Point(e.getX(), e.getY()));
      int colModel = table.convertColumnIndexToModel(col);
      TableSorter model = (TableSorter)table.getModel(); // the table model also implements sorting.

      boolean order;

      if (model.getSortedColumn() == colModel) 
      {
        order = ! model.getCurrentOrder();
      }
      else 
      {
        order = true;
      }

      model.sortByColumn(colModel, order);

      header.repaint();
      table.repaint();
    }

  }

there are no exceptions produced. I hv tried running with jdb. The getValueAt(int, int) function returns the proper value with both java 1.5 and java 1.6 after sorting.

正しい解決策はありません

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top