/** * Implemented to do some tweaks/bookkeeping before/after passing the event to the original * * <p>- temporarily disallow reordering if hit on first column - calculate the max mouseX that's * allowable in dragging to the left */ @Override public void mousePressed(MouseEvent e) { int index = header.columnAtPoint(e.getPoint()); boolean reorderingAllowed = header.getReorderingAllowed(); if (index == 0) { // temporarily disable re-ordering header.setReorderingAllowed(false); } mouseDelegate.mousePressed(e); header.setReorderingAllowed(reorderingAllowed); if (header.getDraggedColumn() != null) { Rectangle r = header.getHeaderRect(index); maxX = header.getColumnModel().getColumn(0).getWidth() + e.getX() - r.x - 1; } }
public void mousePressed(MouseEvent e) { int col = header.columnAtPoint(e.getPoint()); int sortCol = header.getTable().convertColumnIndexToModel(col); renderer.setPressedColumn(col); renderer.setSelectedColumn(col); header.repaint(); if (header.getTable().isEditing()) { header.getTable().getCellEditor().stopCellEditing(); } boolean isAscent; if (SortButtonRenderer.DOWN == renderer.getState(col)) { isAscent = true; } else { isAscent = false; } ((SortableTableModel) header.getTable().getModel()).sortByColumn(sortCol, isAscent); }
public void mousePressed(MouseEvent e) { int col = header.columnAtPoint(e.getPoint()); renderer.setPressedColumn(col); renderer.setSelectedColumn(col); if (col == column) { this.isAscent = !this.isAscent; } else { this.column = col; this.isAscent = true; } this.model.sortByColumn(col, this.isAscent); this.header.getTable().updateUI(); header.repaint(); }
/** * *************************************************************************** * * @param event */ public void mouseReleased(MouseEvent event) { int sortColumn; JTableHeader tableHeader; Point mouseLocation; Rectangle columnHeaderArea; m_sortAscending = !m_sortAscending; mouseLocation = event.getPoint(); tableHeader = getTableHeader(); sortColumn = tableHeader.columnAtPoint(mouseLocation); if (sortColumn >= 0) { // When the cursor is resizing a column, the mouse released event will // reach here. To prevent sorting happening during resizing, the column // header area is inset on the left and right by 10 pixels each. columnHeaderArea = tableHeader.getHeaderRect(sortColumn); columnHeaderArea.x -= 10; columnHeaderArea.width -= 20; if (columnHeaderArea.contains(mouseLocation)) { sort(sortColumn, m_sortAscending); } } }
public void mouseReleased(MouseEvent e) { int col = header.columnAtPoint(e.getPoint()); renderer.setPressedColumn(-1); // clear header.repaint(); }