/** * Sorts the table. * * @param column the column to sort on (zero-based index). * @param ascending a flag to indicate ascending order or descending order. */ public void sortByColumn(final int column, final boolean ascending) { if (isSortable(column)) { this.sortingColumn = column; } }
/** * Sorts the table. * * @param column the column to sort on (zero-based index). * @param ascending a flag to indicate ascending order or descending order. */ public void sortByColumn(final int column, final boolean ascending) { if (isSortable(column)) { this.sortingColumn = column; } }
/** * Sorts the table. * * @param column the column to sort on (zero-based index). * @param ascending a flag to indicate ascending order or descending order. */ public void sortByColumn(final int column, final boolean ascending) { if (isSortable(column)) { this.sortingColumn = column; } }
/** * Handle a mouse press event - if the user is NOT resizing a column and NOT dragging a column * then give visual feedback that the column header has been pressed. * * @param e the mouse event. */ public void mousePressed(final MouseEvent e) { final JTableHeader header = (JTableHeader) e.getComponent(); if (header.getResizingColumn() == null) { // resizing takes precedence over sorting if (header.getDraggedDistance() < 1) { // dragging also takes precedence over sorting final int columnIndex = header.columnAtPoint(e.getPoint()); final int modelColumnIndex = header.getTable().convertColumnIndexToModel(columnIndex); if (this.model.isSortable(modelColumnIndex)) { this.sortColumnIndex = header.getTable().convertColumnIndexToModel(columnIndex); this.renderer.setPressedColumn(this.sortColumnIndex); header.repaint(); if (header.getTable().isEditing()) { header.getTable().getCellEditor().stopCellEditing(); } } else { this.sortColumnIndex = -1; } } } }
/** * Handle a mouse press event - if the user is NOT resizing a column and NOT dragging a column * then give visual feedback that the column header has been pressed. * * @param e the mouse event. */ public void mousePressed(final MouseEvent e) { final JTableHeader header = (JTableHeader) e.getComponent(); if (header.getResizingColumn() == null) { // resizing takes precedence over sorting if (header.getDraggedDistance() < 1) { // dragging also takes precedence over sorting final int columnIndex = header.columnAtPoint(e.getPoint()); final int modelColumnIndex = header.getTable().convertColumnIndexToModel(columnIndex); if (this.model.isSortable(modelColumnIndex)) { this.sortColumnIndex = header.getTable().convertColumnIndexToModel(columnIndex); this.renderer.setPressedColumn(this.sortColumnIndex); header.repaint(); if (header.getTable().isEditing()) { header.getTable().getCellEditor().stopCellEditing(); } } else { this.sortColumnIndex = -1; } } } }
/** * Handle a mouse press event - if the user is NOT resizing a column and NOT dragging a column * then give visual feedback that the column header has been pressed. * * @param e the mouse event. */ public void mousePressed(final MouseEvent e) { final JTableHeader header = (JTableHeader) e.getComponent(); if (header.getResizingColumn() == null) { // resizing takes precedence over sorting if (header.getDraggedDistance() < 1) { // dragging also takes precedence over sorting final int columnIndex = header.columnAtPoint(e.getPoint()); final int modelColumnIndex = header.getTable().convertColumnIndexToModel(columnIndex); if (this.model.isSortable(modelColumnIndex)) { this.sortColumnIndex = header.getTable().convertColumnIndexToModel(columnIndex); this.renderer.setPressedColumn(this.sortColumnIndex); header.repaint(); if (header.getTable().isEditing()) { header.getTable().getCellEditor().stopCellEditing(); } } else { this.sortColumnIndex = -1; } } } }