public void mouseClicked(MouseEvent e) { JTableHeader h = (JTableHeader) e.getSource(); TableColumnModel columnModel = h.getColumnModel(); int viewColumn = columnModel.getColumnIndexAtX(e.getX()); int column = columnModel.getColumn(viewColumn).getModelIndex(); if (column != -1) { int status = getSortingStatus(column); if (!e.isControlDown()) { cancelSorting(); } // Cycle the sorting states through {NOT_SORTED, ASCENDING, DESCENDING} or // {NOT_SORTED, DESCENDING, ASCENDING} depending on whether shift is pressed. status = status + (e.isShiftDown() ? -1 : 1); status = (status + 4) % 3 - 1; // signed mod, returning {-1, 0, 1} setSortingStatus(column, status); } }
public static void FitTableColumns(JTable myTable){ JTableHeader header = myTable.getTableHeader(); int rowCount = myTable.getRowCount(); Enumeration columns = myTable.getColumnModel().getColumns(); while(columns.hasMoreElements()){ TableColumn column = (TableColumn)columns.nextElement(); int col = header.getColumnModel().getColumnIndex(column.getIdentifier()); int width = (int)myTable.getTableHeader().getDefaultRenderer() .getTableCellRendererComponent(myTable, column.getIdentifier() , false, false, -1, col).getPreferredSize().getWidth(); for(int row = 0; row<rowCount; row++){ int preferedWidth = (int)myTable.getCellRenderer(row, col).getTableCellRendererComponent(myTable, myTable.getValueAt(row, col), false, false, row, col).getPreferredSize().getWidth(); width = Math.max(width, preferedWidth); } header.setResizingColumn(column); // ���к���Ҫ column.setWidth(width+myTable.getIntercellSpacing().width); } }
@Override public Object getDesignValue() { Object value = null; try { value = property.getTargetValue(); if (value instanceof JTableHeader) { JTableHeader header = (JTableHeader)value; header.setResizingAllowed(resizingAllowed); header.setReorderingAllowed(reorderingAllowed); } } catch (IllegalAccessException iaex) { Logger.getLogger(getClass().getName()).log(Level.INFO, iaex.getMessage(), iaex); } catch (InvocationTargetException itex) { Logger.getLogger(getClass().getName()).log(Level.INFO, itex.getMessage(), itex); } return value; }
/** Overridden - JTable's implementation of the method will * actually attach (and leave behind) a gratuitous border * on the enclosing scroll pane. */ @Override protected final void configureEnclosingScrollPane() { Container p = getParent(); if (p instanceof JViewport) { Container gp = p.getParent(); if (gp instanceof JScrollPane) { JScrollPane scrollPane = (JScrollPane) gp; JViewport viewport = scrollPane.getViewport(); if ((viewport == null) || (viewport.getView() != this)) { return; } JTableHeader jth = getTableHeader(); if (jth != null) { jth.setBorder(null); } scrollPane.setColumnHeaderView(jth); } } }
@Override public void mouseClicked(MouseEvent e) { JTableHeader h = (JTableHeader) e.getSource(); TableColumnModel columnModel = h.getColumnModel(); int viewColumn = columnModel.getColumnIndexAtX(e.getX()); int column = columnModel.getColumn(viewColumn).getModelIndex(); if (column != -1) { int status = getSortingStatus(column); if (!e.isControlDown()) { cancelSorting(); } // Cycle the sorting states through {NOT_SORTED, ASCENDING, DESCENDING} or // {NOT_SORTED, DESCENDING, ASCENDING} depending on whether shift is pressed. status += e.isShiftDown() ? -1 : 1; status = (status + 4) % 3 - 1; // signed mod, returning {-1, 0, 1} setSortingStatus(column, status); if(issueTable != null) { issueTable.sortOrderChanged(); } } }
public void setTableHeader(JTableHeader tableHeader) { if (this.tableHeader != null) { this.tableHeader.removeMouseListener(mouseListener); TableCellRenderer defaultRenderer = this.tableHeader.getDefaultRenderer(); if (defaultRenderer instanceof SortableHeaderRenderer) { this.tableHeader.setDefaultRenderer( ((SortableHeaderRenderer) defaultRenderer) .tableCellRenderer); } } this.tableHeader = tableHeader; if (this.tableHeader != null) { this.tableHeader.addMouseListener(mouseListener); this.tableHeader.setDefaultRenderer( new SortableHeaderRenderer( this.tableHeader.getDefaultRenderer())); } }
public void addMouseListenerToHeaderInTable(JTable table) { final TableSorter sorter = this; final JTable tableView = table; tableView.setColumnSelectionAllowed(false); MouseAdapter listMouseListener = new MouseAdapter() { boolean ascending = false; public void mouseClicked(MouseEvent e) { TableColumnModel columnModel = tableView.getColumnModel(); int viewColumn = columnModel.getColumnIndexAtX(e.getX()); int column = tableView.convertColumnIndexToModel(viewColumn); if (e.getClickCount() == 1 && column != -1) { //System.out.println("Sorting ..."); //int shiftPressed = e.getModifiers()&InputEvent.SHIFT_MASK; //boolean ascending = (shiftPressed == 0); if (column == sortBy) ascending = !ascending; else ascending = true; sorter.sortByColumn(column, ascending); tableView.getTableHeader().updateUI(); } } }; JTableHeader th = tableView.getTableHeader(); th.addMouseListener(listMouseListener); }
public void setTableHeader(JTableHeader tableHeader) { if( this.tableHeader != null ) { this.tableHeader.removeMouseListener(mouseListener); TableCellRenderer defaultRenderer = this.tableHeader.getDefaultRenderer(); if( defaultRenderer instanceof SortableHeaderRenderer ) { this.tableHeader.setDefaultRenderer(((SortableHeaderRenderer) defaultRenderer).tableCellRenderer); } } this.tableHeader = tableHeader; if( this.tableHeader != null ) { this.tableHeader.addMouseListener(mouseListener); this.tableHeader.setDefaultRenderer(new SortableHeaderRenderer(this.tableHeader.getDefaultRenderer())); } }
public static void sizeColumnsToFit2(JTable table, int columnMargin,DataNode line){ JTableHeader tableHeader = table.getTableHeader(); FontMetrics lineFontMetrics = table.getFontMetrics(table.getFont()); FontMetrics headerFontMetrics = tableHeader.getFontMetrics(tableHeader.getFont()); //System.out.println(line+" MaxColumnLength: "+line.getMaxColumnLength()); for (int t=0; t<table.getRowCount();t++){ for (int tt=0; tt<table.getColumnCount();tt++){ table.getColumnModel().getColumn(tt).setPreferredWidth( (columnMargin*2)+line.getMaxColumnLength().get(table.getColumnName(tt))*lineFontMetrics.charsWidth("ABCD1834".toCharArray(),0,8)/8 ); tableHeader.getColumnModel().getColumn(tt).setPreferredWidth( (columnMargin*2)+line.getMaxColumnLength().get(table.getColumnName(tt))*headerFontMetrics.charsWidth("ABCDabcd1834".toCharArray(),0,12)/12 ); //System.out.println("Zeile "+t+" Spalte "+tt+" "+" getPreferredWidth"+table.getColumnModel().getColumn(tt).getPreferredWidth()+" line.getMaxColumnLength"+line.getMaxColumnLength().get(table.getColumnName(t))); } } }
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int col) { boolean timelineColumn = column == table.convertColumnIndexToModel(col); setVisible(timelineColumn); Component c = impl.getTableCellRendererComponent(table, timelineColumn ? " " : value, isSelected, hasFocus, row, col); // NOI18N if (timelineColumn) { if (getParent() == null && c instanceof Container) ((Container)c).add(this); JTableHeader header = table.getTableHeader(); if (painter == null) initStaticUI(c, header); TableColumn _column = header.getColumnModel().getColumn(col); setSize(_column.getWidth(), header.getSize().height); } return c; }
private static void initStaticUI(Component c, JTableHeader header) { painter = new LabelRenderer(true); Color color = c.getForeground(); if (color == null) color = header.getForeground(); if (color == null) color = UIManager.getColor("TableHeader.foreground"); // NOI18N if (color != null) painter.setForeground(color); Font font = c.getFont(); if (font == null) font = header.getFont(); if (font == null) font = UIManager.getFont("TableHeader.font"); // NOI18N if (font != null) painter.setFont(font); if (UIUtils.isWindowsXPLookAndFeel()) Y_LAF_OFFSET = 1; else if (UIUtils.isNimbusLookAndFeel()) Y_LAF_OFFSET = -1; else Y_LAF_OFFSET = 0; }
public Component getTableCellRendererComponent (JTable table, Object value, boolean isSelected, boolean hasFocus,int row, int column) { if (table != null) { JTableHeader header = table.getTableHeader(); if (header != null) { setForeground(header.getForeground()); setBackground(header.getBackground()); setFont(header.getFont()); } } AttlistTableModel tm = (AttlistTableModel)table.getModel(); if (column == tm.SortedColumn) setIcon(tm.ascending ? new javax.swing.ImageIcon(getClass().getResource("down.gif")): // NOI18N new javax.swing.ImageIcon(getClass().getResource("up.gif"))); // NOI18N else setIcon(new javax.swing.ImageIcon(getClass().getResource("no.gif"))); // NOI18N setText((value == null) ? "" : value.toString()); // NOI18N return this; }
/** * Enables/disables all subcomponents of this panel. This also toggles the ability to drag and * drop and conditionally freezes the ability to resize the file list column headers. * * @param enabled * Whether or not this panel is enabled */ private void subSetEnabled(final boolean enabled) { if (!SwingUtilities.isEventDispatchThread()) { String errMsg = "subSetEnabled is not on the EDT but it should be"; IllegalStateException ex = new IllegalStateException(errMsg); LOG.log(Level.SEVERE, errMsg, ex); throw ex; } enableDragAndDrop(enabled); GUIHelper.enableComponent(this, enabled); setEnabled(true); // Re-enable the panel since GUIHelper.enableComponent disables it sslButton.setEnabled(enabled && profileModel.getProfileAdapter() != null && profileModel.getProfileAdapter().getSSLCertChain() != null); browseDirectoryButton .setEnabled(enabled && getSelectedProfile().getType() == ProfileType.FILESYSTEM); JTableHeader header = fileList.getTableHeader(); if (header != null) { header.setResizingAllowed(enabled); } }
public void addMouseListenerToHeaderInTable(JTable table) { final TableSorter sorter = this; final JTable tableView = table; tableView.setColumnSelectionAllowed(false); MouseAdapter listMouseListener = new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { TableColumnModel columnModel = tableView.getColumnModel(); int viewColumn = columnModel.getColumnIndexAtX(e.getX()); int column = tableView.convertColumnIndexToModel(viewColumn); if (e.getClickCount() == 1 && column != -1) { System.out.println("Sorting ..."); int shiftPressed = e.getModifiers() & InputEvent.SHIFT_MASK; boolean ascending = (shiftPressed == 0); sorter.sortByColumn(column, ascending); } } }; JTableHeader th = tableView.getTableHeader(); th.addMouseListener(listMouseListener); }
@Override public void mouseClicked(MouseEvent e) { if (!e.isPopupTrigger()) { JTableHeader h = (JTableHeader) e.getSource(); TableColumnModel columnModel = h.getColumnModel(); int viewColumn = columnModel.getColumnIndexAtX(e.getX()); int column = columnModel.getColumn(viewColumn).getModelIndex(); if (column != -1) { if (columnModel.getColumn(viewColumn).getHeaderValue().equals("File Name")) { FileTable.this.fileList.orderBy(FileList.ORDER_BY_FILE_NAME, false); FileTable.this.fileList.updateTableData(); } else if (columnModel.getColumn(viewColumn).getHeaderValue().equals("Type")) { FileTable.this.fileList.orderBy(FileList.ORDER_BY_FILE_TYPE, false); FileTable.this.fileList.updateTableData(); } else if (columnModel.getColumn(viewColumn).getHeaderValue().equals("Last Modified")) { FileTable.this.fileList.orderBy(FileList.ORDER_BY_FILE_MODIFIED, false); FileTable.this.fileList.updateTableData(); } else if (columnModel.getColumn(viewColumn).getHeaderValue().equals("Size")) { FileTable.this.fileList.orderBy(FileList.ORDER_BY_FILE_SIZE, false); FileTable.this.fileList.updateTableData(); } } } }
@Override public void mouseClicked(MouseEvent e) { synchFilechooser(); if (e.getClickCount() == 2 && !(e.getSource() instanceof JTableHeader)) { this.row = ((JTable) e.getComponent()).rowAtPoint(e.getPoint()); this.column = ((JTable) e.getComponent()).columnAtPoint(e.getPoint()); if (getColumnName(this.column).equals(getColumnName(this.mainColumnIndex)) && this.row > -1) { this.tempItem = this.fileList.visibleItemsList.elementAt(this.row); if (this.tempItem.isDirectory()) { this.fileList.filechooserUI.setCurrentDirectoryOfFileChooser(this.tempItem.getFile()); } else { this.fileList.fc.setSelectedFile(this.tempItem.getFile()); this.fileList.filechooserUI.getApproveSelectionAction().actionPerformed(null); } } } }
/** This method ensures that the correct tool tip for the current column is delivered. */ @Override protected JTableHeader createDefaultTableHeader() { return new JTableHeader(columnModel) { private static final long serialVersionUID = 1L; @Override public String getToolTipText(MouseEvent e) { java.awt.Point p = e.getPoint(); int index = columnModel.getColumnIndexAtX(p.x); int realColumnIndex = convertColumnIndexToModel(index); if (realColumnIndex == 0) { return "The names of the parameters."; } else { return "The values of the parameters."; } } }; }
private TableColumn getResizingColumn(JTableHeader header, Point p, int column) { if (column == -1) { return null; } Rectangle r = header.getHeaderRect(column); r.grow(-3, 0); if (r.contains(p)) { return null; } int midPoint = r.x + r.width / 2; int columnIndex = 0; if (header.getComponentOrientation().isLeftToRight()) { columnIndex = (p.x < midPoint) ? column - 1 : column; } else { columnIndex = (p.x < midPoint) ? column : column - 1; } if (columnIndex == -1) { return null; } return header.getColumnModel().getColumn(columnIndex); }
public void mouseClicked(MouseEvent e) { JTableHeader h = (JTableHeader) e.getSource(); TableColumnModel columnModel = h.getColumnModel(); int viewColumn = h.columnAtPoint(e.getPoint()); int column = columnModel.getColumn(viewColumn).getModelIndex(); if (column != -1) { int status = getSortingStatus(column); if (!e.isControlDown()) { cancelSorting(); } // Cycle the sorting states through {NOT_SORTED, ASCENDING, DESCENDING} or // {NOT_SORTED, DESCENDING, ASCENDING} depending on whether shift is pressed. status = status + (e.isShiftDown() ? -1 : 1); status = (status + 4) % 3 - 1; // signed mod, returning {-1, 0, 1} setSortingStatus(column, status); } }
@Override public void mouseClicked(MouseEvent e) { JTableHeader h = (JTableHeader) e.getSource(); TableColumnModel columnModel = h.getColumnModel(); int viewColumn = getSortingColumnIndex(h, e.getPoint()); if (viewColumn != -1) { int column = columnModel.getColumn(viewColumn).getModelIndex(); if (column != -1) { int status = getSortingStatus(column); if (!SwingTools.isControlOrMetaDown(e)) { cancelSorting(); } // Cycle the sorting states through {NOT_SORTED, ASCENDING, DESCENDING} or // {NOT_SORTED, DESCENDING, ASCENDING} depending on whether shift is // pressed. status = status + (e.isShiftDown() ? -1 : 1); status = (status + 4) % 3 - 1; // signed mod, returning {-1, 0, 1} setSortingStatus(column, status); } e.consume(); } }
public void setSortingStatus(final int status, final boolean cancelSorting) { if (getModel() instanceof ExtendedJTableSorterModel) { ExtendedJTableSorterModel sorterModel = (ExtendedJTableSorterModel) getModel(); JTableHeader h = getTableHeader(); TableColumnModel columnModel = h.getColumnModel(); int viewColumn = getSelectedColumn(); if (viewColumn != -1) { int column = columnModel.getColumn(viewColumn).getModelIndex(); if (column != -1) { if (sorterModel.isSorting()) { if (cancelSorting) { sorterModel.cancelSorting(); } } sorterModel.setSortingStatus(column, status); } } } }
/** * Erzeugt die Tabelle für die Anzeige der Medien. */ private void erzeugeMedienTable() { JScrollPane medienAuflisterScrollPane = new JScrollPane(); medienAuflisterScrollPane.setBorder(BorderFactory.createTitledBorder( null, "Medien", TitledBorder.LEADING, TitledBorder.DEFAULT_POSITION, UIConstants.HEADER_FONT)); medienAuflisterScrollPane.setBackground(UIConstants.BACKGROUND_COLOR); medienAuflisterScrollPane.getVerticalScrollBar() .setBackground(UIConstants.BACKGROUND_COLOR); medienAuflisterScrollPane.getHorizontalScrollBar() .setBackground(UIConstants.BACKGROUND_COLOR); _medienTableModel = new VormerkMedienTableModel(); _medienTable = new JTable(); medienAuflisterScrollPane.setViewportView(_medienTable); _medienTable.setModel(_medienTableModel); JTableHeader tableHeader = _medienTable.getTableHeader(); tableHeader.setFont(UIConstants.HEADER_FONT); tableHeader.setReorderingAllowed(false); tableHeader.setResizingAllowed(false); _medienTable.setFont(UIConstants.TEXT_FONT); _hauptPanel.add(medienAuflisterScrollPane, BorderLayout.CENTER); }
/** This method ensures that the correct tool tip for the current column is delivered. */ @Override protected JTableHeader createDefaultTableHeader() { JTableHeader header = new JTableHeader(columnModel) { private static final long serialVersionUID = 1L; @Override public String getToolTipText(MouseEvent e) { java.awt.Point p = e.getPoint(); int index = columnModel.getColumnIndexAtX(p.x); int realColumnIndex = convertColumnIndexToModel(index); return DataViewerTable.this.getHeaderToolTipText(realColumnIndex); } }; header.putClientProperty(RapidLookTools.PROPERTY_TABLE_HEADER_BACKGROUND, Colors.WHITE); return header; }
@Override public void mouseMoved(MouseEvent evt) { TableColumn col = null; JTableHeader header = (JTableHeader) evt.getSource(); JTable table = header.getTable(); TableColumnModel colModel = table.getColumnModel(); int vColIndex = colModel.getColumnIndexAtX(evt.getX()); // Return if not clicked on any column header if (vColIndex >= 0) { col = colModel.getColumn(vColIndex); } if (col != curCol) { header.setToolTipText(tips.get(col)); curCol = col; } }
public static void reset() { add(Component.class, JavaElement.class); add(JList.class, JListJavaElement.class); add(JTabbedPane.class, JTabbedPaneJavaElement.class); add(JComboBox.class, JComboBoxJavaElement.class); add(JTable.class, JTableJavaElement.class); add(JTableHeader.class, JTableHeaderJavaElement.class); add(JTree.class, JTreeJavaElement.class); add(JToggleButton.class, JToggleButtonJavaElement.class); add(JSpinner.class, JSpinnerJavaElement.class); add(JProgressBar.class, JProgressBarJavaElement.class); add(JSplitPane.class, JSplitPaneJavaElement.class); add(JTextComponent.class, JTextComponentJavaElement.class); add(EditorContainer.class, JTreeEditingContainerJavaElement.class); add(JEditorPane.class, JEditorPaneJavaElement.class); add(JMenuItem.class, JMenuItemJavaElement.class); add(JSlider.class, JSliderJavaElement.class); add(JSpinner.class, JSpinnerJavaElement.class); add(DefaultEditor.class, DefaultEditorJavaElement.class); add(JColorChooser.class, JColorChooserJavaElement.class); add(JFileChooser.class, JFileChooserJavaElement.class); }
/** * Erzeuge das Tabellen-Panel, in dem die Verleihkarten angezeigt werden. */ private void erzeugeVerleihkartenauflister() { JPanel verleihkartenAuflisterPanel = new JPanel(); _hauptPanel.add(verleihkartenAuflisterPanel, BorderLayout.CENTER); verleihkartenAuflisterPanel.setLayout(new BorderLayout()); verleihkartenAuflisterPanel .setPreferredSize(new java.awt.Dimension(-1, -1)); verleihkartenAuflisterPanel.setSize(-1, -1); verleihkartenAuflisterPanel.setBackground(UIConstants.BACKGROUND_COLOR); JScrollPane verleihkartenAuflisterScrollPane = new JScrollPane(); verleihkartenAuflisterPanel.add(verleihkartenAuflisterScrollPane, BorderLayout.CENTER); verleihkartenAuflisterScrollPane .setPreferredSize(new java.awt.Dimension(-1, -1)); verleihkartenAuflisterScrollPane.setSize(-1, -1); verleihkartenAuflisterScrollPane.setBorder(BorderFactory .createTitledBorder(null, "Verleihkarten", TitledBorder.LEADING, TitledBorder.DEFAULT_POSITION, UIConstants.HEADER_FONT)); verleihkartenAuflisterScrollPane .setBackground(UIConstants.BACKGROUND_COLOR); verleihkartenAuflisterScrollPane.getVerticalScrollBar() .setBackground(UIConstants.BACKGROUND_COLOR); verleihkartenAuflisterScrollPane.getHorizontalScrollBar() .setBackground(UIConstants.BACKGROUND_COLOR); _verleihkartenAuflisterTableModel = new VerleihkartenTableModel(); _verleihkartenAuflisterTable = new JTable(); verleihkartenAuflisterScrollPane .setViewportView(_verleihkartenAuflisterTable); _verleihkartenAuflisterTable .setModel(_verleihkartenAuflisterTableModel); JTableHeader tableHeader = _verleihkartenAuflisterTable .getTableHeader(); tableHeader.setFont(UIConstants.HEADER_FONT); tableHeader.setReorderingAllowed(false); tableHeader.setResizingAllowed(false); _verleihkartenAuflisterTable.setFont(UIConstants.TEXT_FONT); }
@BeforeMethod public void showDialog() throws Throwable { SwingUtilities.invokeAndWait(new Runnable() { @Override public void run() { frame = new JFrame(JTableHeaderJavaElementTest.class.getSimpleName()); frame.setName("frame-" + JTableHeaderJavaElementTest.class.getSimpleName()); TableDemo demo = new TableDemo(); demo.start(); frame.getContentPane().add(demo, BorderLayout.CENTER); frame.pack(); frame.setAlwaysOnTop(true); frame.setVisible(true); } }); driver = new JavaAgent(); JavaElementFactory.add(JTableHeader.class, JTableHeaderJavaElement.class); }
public static void reset() { entries.clear(); add(Component.class, RUnknownComponent.class); add(Window.class, RWindow.class); add(JTable.class, RTable.class); add(JTableHeader.class, RTableHeader.class); add(AbstractButton.class, RAbstractButton.class); add(JToggleButton.class, RToggleButton.class); add(JComboBox.class, RComboBox.class); add(JTextComponent.class, RTextComponent.class); add(JTree.class, RTree.class); add(JList.class, RList.class); add(JTabbedPane.class, RTabbedPane.class); add(JMenuItem.class, RMenuItem.class); add(JSlider.class, RSlider.class); add(JProgressBar.class, RProgressBar.class); add(JSpinner.class, RSpinner.class); add(DefaultEditor.class, RDefaultEditor.class); add(JColorChooser.class, RColorChooser.class); add(JSplitPane.class, RSplitPane.class); add(BasicSplitPaneDivider.class, RSplitPane.class); add(JFileChooser.class, RFileChooser.class); add(JEditorPane.class, REditorPane.class); add(JLabel.class, RLabel.class); add(JScrollBar.class, RIgnoreComponent.class); }
/** * It creates a new instance of the group activating / de-acticating panel. * * @param dataset The dataset that holds whether the groups are * activated / de-activated and that will be notified when changes * are made. */ public GroupActivatingPanel(DatasetWithGroups dataset, Locker locker) { this.dataset = dataset; this.locker = locker; this.model = new Model(); initComponents(); table.setDefaultRenderer(String.class, new StringRenderer()); table.setDefaultRenderer(Boolean.class, new BooleanRenderer()); JTableHeader header = table.getTableHeader(); header.setReorderingAllowed(false); GUIUtilities.setTableHeader(header); table.setModel(model); }
@Override public void mouseClicked(MouseEvent e) { JTableHeader h = (JTableHeader) e.getSource(); TableColumnModel columnModel = h.getColumnModel(); int viewColumn = columnModel.getColumnIndexAtX(e.getX()); int column = columnModel.getColumn(viewColumn).getModelIndex(); if (column != -1) { int status = getSortingStatus(column); if (!e.isControlDown()) { cancelSorting(); } // Cycle the sorting states through {NOT_SORTED, ASCENDING, // DESCENDING} or // {NOT_SORTED, DESCENDING, ASCENDING} depending on whether // shift is pressed. status = status + (e.isShiftDown() ? -1 : 1); status = (status + 4) % 3 - 1; // signed mod, returning {-1, 0, // 1} setSortingStatus(column, status); } }