final JTable table = new JXTable(new AncientSwingTeam()); table.setRowSorter(new MyTableRowSorter(table.getModel())); Action toggle = new AbstractAction("toggleSort") { @Override public void actionPerformed(ActionEvent e) { JXTableHeader header = SwingXUtilities.getAncestor( JXTableHeader.class, (Component) e.getSource()); Point trigger = header.getPopupTriggerLocation(); int column = trigger != null ? header.columnAtPoint(trigger) : -1; if (column < 0) return; int modelColumn = header.getTable().convertColumnIndexToModel(column); ((MyTableRowSorter) header.getTable().getRowSorter()) .realToggleSortOrder(modelColumn); } }; JPopupMenu menu = new JPopupMenu(); menu.add(toggle); table.getTableHeader().setComponentPopupMenu(menu);
private void cacheSortColumn(MouseEvent e) { if (!canCacheSortColumn(e)) uncacheSortColumn(); if (e.getClickCount() % 2 == 1) { int column = columnAtPoint(e.getPoint()); if (column >= 0) { int primarySortIndex = getXTable().getSortedColumnIndex(); if (primarySortIndex == column) { column = -1; } } sortColumn = column; } }
private void cacheSortColumn(MouseEvent e) { if (!canCacheSortColumn(e)) uncacheSortColumn(); if (e.getClickCount() % 2 == 1) { int column = columnAtPoint(e.getPoint()); if (column >= 0) { int primarySortIndex = getXTable().getSortedColumnIndex(); if (primarySortIndex == column) { column = -1; } } sortColumn = column; } }
private void cacheSortColumn(MouseEvent e) { if (!canCacheSortColumn(e)) uncacheSortColumn(); if (e.getClickCount() % 2 == 1) { int column = columnAtPoint(e.getPoint()); if (column >= 0) { int primarySortIndex = getXTable().getSortedColumnIndex(); if (primarySortIndex == column) { column = -1; } } sortColumn = column; } }
private void cacheSortColumn(MouseEvent e) { if (!canCacheSortColumn(e)) uncacheSortColumn(); if (e.getClickCount() % 2 == 1) { int column = columnAtPoint(e.getPoint()); if (column >= 0) { int primarySortIndex = getXTable().getSortedColumnIndex(); if (primarySortIndex == column) { column = -1; } } sortColumn = column; } }
/** * Returns the column tooltip of the column at the position * of the MouseEvent, if a tooltip is available. * * @param event the mouseEvent representing the mouse location. * @return the column tooltip of the column below the mouse location, * or null if not available. */ protected String getColumnToolTipText(MouseEvent event) { if (getXTable() == null) return null; int column = columnAtPoint(event.getPoint()); if (column < 0) return null; TableColumnExt columnExt = getXTable().getColumnExt(column); return columnExt != null ? columnExt.getToolTipText() : null; }
/** * Returns the column tooltip of the column at the position * of the MouseEvent, if a tooltip is available. * * @param event the mouseEvent representing the mouse location. * @return the column tooltip of the column below the mouse location, * or null if not available. */ protected String getColumnToolTipText(MouseEvent event) { if (getXTable() == null) return null; int column = columnAtPoint(event.getPoint()); if (column < 0) return null; TableColumnExt columnExt = getXTable().getColumnExt(column); return columnExt != null ? columnExt.getToolTipText() : null; }
/** * Returns the column tooltip of the column at the position * of the MouseEvent, if a tooltip is available. * * @param event the mouseEvent representing the mouse location. * @return the column tooltip of the column below the mouse location, * or null if not available. */ protected String getColumnToolTipText(MouseEvent event) { if (getXTable() == null) return null; int column = columnAtPoint(event.getPoint()); if (column < 0) return null; TableColumnExt columnExt = getXTable().getColumnExt(column); return columnExt != null ? columnExt.getToolTipText() : null; }
/** * Returns the column tooltip of the column at the position * of the MouseEvent, if a tooltip is available. * * @param event the mouseEvent representing the mouse location. * @return the column tooltip of the column below the mouse location, * or null if not available. */ protected String getColumnToolTipText(MouseEvent event) { if (getXTable() == null) return null; int column = columnAtPoint(event.getPoint()); if (column < 0) return null; TableColumnExt columnExt = getXTable().getColumnExt(column); return columnExt != null ? columnExt.getToolTipText() : null; }
/** * Returns the column tooltip of the column at the position * of the MouseEvent, if a tooltip is available. * * @param event the mouseEvent representing the mouse location. * @return the column tooltip of the column below the mouse location, * or null if not available. */ protected String getColumnToolTipText(MouseEvent event) { if (getXTable() == null) return null; int column = columnAtPoint(event.getPoint()); if (column < 0) return null; TableColumnExt columnExt = getXTable().getColumnExt(column); return columnExt != null ? columnExt.getToolTipText() : null; }
private void doSort(MouseEvent e) { JXTable table = getXTable(); if (!table.isSortable()) return; if (getSortGestureRecognizer().isResetSortOrderGesture(e)) { table.resetSortOrder(); repaint(); } else if (getSortGestureRecognizer().isToggleSortOrderGesture(e)){ int column = columnAtPoint(e.getPoint()); if (column >= 0) { table.toggleSortOrder(column); } uncacheResizingColumn(); repaint(); } }