List of usage examples for javax.swing.table JTableHeader removeMouseListener
public synchronized void removeMouseListener(MouseListener l)
From source file:com.mirth.connect.client.ui.components.MirthTreeTable.java
@Override public void setSortable(boolean enable) { super.setSortable(enable); JTableHeader header = getTableHeader(); if (enable) { if (treeTableSortAdapter == null) { treeTableSortAdapter = new MouseAdapter() { public void mouseClicked(MouseEvent e) { if (SwingUtilities.isLeftMouseButton(e)) { JTableHeader h = (JTableHeader) e.getSource(); TableColumnModel columnModel = getColumnModel(); int viewColumn = h.columnAtPoint(e.getPoint()); int column = columnModel.getColumn(viewColumn).getModelIndex(); if (column != -1) { beforeSort(); // Toggle sort order (ascending <-> descending) SortableTreeTableModel model = (SortableTreeTableModel) getTreeTableModel(); model.setColumnAndToggleSortOrder(column); // Set sorting icon and current column index ((SortableHeaderCellRenderer) getTableHeader().getDefaultRenderer()) .setSortingIcon(model.getSortOrder()); ((SortableHeaderCellRenderer) getTableHeader().getDefaultRenderer()) .setColumnIndex(column); saveSortPreferences(column); afterSort(); }/*from ww w. j ava2 s .c om*/ } } }; header.addMouseListener(treeTableSortAdapter); } } else { if (treeTableSortAdapter != null) { header.removeMouseListener(treeTableSortAdapter); treeTableSortAdapter = null; } } }