/** * Checks if row is in range: 0 <= row < getRowCount(). * * @param column the column index to check in view coordinates. * @return true if the column is in range, false otherwise */ private boolean isValidColumn(int column) { return column >= 0 && column < table.getColumnCount(); }
/** * Checks if row is in range: 0 <= row < getRowCount(). * * @param column the column index to check in view coordinates. * @return true if the column is in range, false otherwise */ private boolean isValidColumn(int column) { return column >= 0 && column < table.getColumnCount(); }
/** * Checks if row is in range: 0 <= row < getRowCount(). * * @param column the column index to check in view coordinates. * @return true if the column is in range, false otherwise */ private boolean isValidColumn(int column) { return column >= 0 && column < table.getColumnCount(); }
/** * Checks if row is in range: 0 <= row < getRowCount(). * * @param column the column index to check in view coordinates. * @return true if the column is in range, false otherwise */ private boolean isValidColumn(int column) { return column >= 0 && column < table.getColumnCount(); }
/** * Checks if row is in range: 0 <= row < getRowCount(). * * @param column the column index to check in view coordinates. * @return true if the column is in range, false otherwise */ private boolean isValidColumn(int column) { return column >= 0 && column < table.getColumnCount(); }
/** * {@inheritDoc} * <p> * * Overridden to loop through all columns in a row. */ @Override protected int moveStartPosition(int startRow, boolean backwards) { if (backwards) { lastSearchResult.foundColumn--; if (lastSearchResult.foundColumn < 0) { startRow--; } } else { lastSearchResult.foundColumn++; if (lastSearchResult.foundColumn >= table.getColumnCount()) { lastSearchResult.foundColumn = -1; startRow++; } } return startRow; }
/** * {@inheritDoc} * <p> * * Overridden to loop through all columns in a row. */ @Override protected int moveStartPosition(int startRow, boolean backwards) { if (backwards) { lastSearchResult.foundColumn--; if (lastSearchResult.foundColumn < 0) { startRow--; } } else { lastSearchResult.foundColumn++; if (lastSearchResult.foundColumn >= table.getColumnCount()) { lastSearchResult.foundColumn = -1; startRow++; } } return startRow; }
/** * {@inheritDoc} * <p> * * Overridden to loop through all columns in a row. */ @Override protected int moveStartPosition(int startRow, boolean backwards) { if (backwards) { lastSearchResult.foundColumn--; if (lastSearchResult.foundColumn < 0) { startRow--; } } else { lastSearchResult.foundColumn++; if (lastSearchResult.foundColumn >= table.getColumnCount()) { lastSearchResult.foundColumn = -1; startRow++; } } return startRow; }
/** * Packs all the columns to their optimal size. Works best with auto * resizing turned off. * * @param margin the margin to apply to each column. * * @see #packColumn(int, int) * @see #packColumn(int, int, int) */ public void packTable(int margin) { for (int c = 0; c < getColumnCount(); c++) packColumn(c, margin, -1); }
/** * Packs all the columns to their optimal size. Works best with auto * resizing turned off. * * @param margin the margin to apply to each column. * * @see #packColumn(int, int) * @see #packColumn(int, int, int) */ public void packTable(int margin) { for (int c = 0; c < getColumnCount(); c++) packColumn(c, margin, -1); }
/** * Packs all the columns to their optimal size. Works best with auto * resizing turned off. * * @param margin the margin to apply to each column. * * @see #packColumn(int, int) * @see #packColumn(int, int, int) */ public void packTable(int margin) { for (int c = 0; c < getColumnCount(); c++) packColumn(c, margin, -1); }
/** * Packs all the columns to their optimal size. Works best with auto * resizing turned off. * * @param margin the margin to apply to each column. * * @see #packColumn(int, int) * @see #packColumn(int, int, int) */ public void packTable(int margin) { for (int c = 0; c < getColumnCount(); c++) packColumn(c, margin, -1); }
/** * Packs all the columns to their optimal size. Works best with auto * resizing turned off. * * @param margin the margin to apply to each column. * * @see #packColumn(int, int) * @see #packColumn(int, int, int) */ public void packTable(int margin) { for (int c = 0; c < getColumnCount(); c++) packColumn(c, margin, -1); }
private static class StringTableModel extends AbstractTableModel { private JXTable delegateTable; private StringTableModel(JXTable aTable) { delegateTable = aTable; } @Override public int getRowCount() { return delegateTable.getRowCount(); } @Override public int getColumnCount() { return delegateTable.getColumnCount(); } @Override public Object getValueAt(int aRowIndex, int aColumnIndex) { return delegateTable.getStringAt(aRowIndex, aColumnIndex); } }
@Override public void itemStateChanged(final ItemEvent e) { if (canControlColumn()) { if ((e.getStateChange() == ItemEvent.DESELECTED) //JW: guarding against 1 leads to #212-swingx: setting // column visibility programatically fails if // the current column is the second last visible // guarding against 0 leads to hiding all columns // by deselecting the menu item. && (table.getColumnCount() <= 1) // JW Fixed #212: basically implemented Rob's idea to distinguish // event sources instead of unconditionally reselect // not entirely sure if the state transitions are completely // defined but all related tests are passing now. && !fromColumn) { reselect(); } else { setSelected(e.getStateChange() == ItemEvent.SELECTED); } } }
@Override public void itemStateChanged(final ItemEvent e) { if (canControlColumn()) { if ((e.getStateChange() == ItemEvent.DESELECTED) //JW: guarding against 1 leads to #212-swingx: setting // column visibility programatically fails if // the current column is the second last visible // guarding against 0 leads to hiding all columns // by deselecting the menu item. && (table.getColumnCount() <= 1) // JW Fixed #212: basically implemented Rob's idea to distinguish // event sources instead of unconditionally reselect // not entirely sure if the state transitions are completely // defined but all related tests are passing now. && !fromColumn) { reselect(); } else { setSelected(e.getStateChange() == ItemEvent.SELECTED); } } }
/** * Searches forward through columns of the given row. Starts at * lastFoundColumn or first column if lastFoundColumn < 0. returns an * appropriate SearchResult if a matching cell is found in this row or null * if no match is found. A row index out off range results in a no-match. * * @param pattern <code>Pattern</code> that we will try to locate * @param row the row to search * @return an appropriate <code>SearchResult</code> if a matching cell is * found in this row or null if no match is found */ private SearchResult findMatchBackwardsInRow(Pattern pattern, int row) { int startColumn = (lastSearchResult.foundColumn < 0) ? table .getColumnCount() - 1 : lastSearchResult.foundColumn; if (isValidIndex(row)) { for (int column = startColumn; column >= 0; column--) { SearchResult result = findMatchAt(pattern, row, column); if (result != null) return result; } } return null; }
public void propertyChange(PropertyChangeEvent event) { String prop = event.getPropertyName(); if (prop.equalsIgnoreCase(GrammarVizMessage.MAIN_CHART_CLICKED_MESSAGE)) { String rule = (String) event.getNewValue(); for (int row = 0; row <= sequiturTable.getRowCount() - 1; row++) { for (int col = 0; col <= sequiturTable.getColumnCount() - 1; col++) { if (rule.equals(this.session.chartData.convert2OriginalSAXAlphabet('1', sequiturTable.getValueAt(row, col).toString()))) { sequiturTable.scrollRectToVisible(sequiturTable.getCellRect(row, 0, true)); sequiturTable.setRowSelectionInterval(row, row); } } } } }
private void setParamsTableColumnSizes() { for (int i = 0; i < paramsTable.getColumnCount(); i++) { DefaultTableColumnModel colModel = (DefaultTableColumnModel) paramsTable.getColumnModel(); TableColumn col = colModel.getColumn(i); int width = 0; TableCellRenderer renderer = col.getHeaderRenderer(); if (renderer == null) { renderer = paramsTable.getTableHeader().getDefaultRenderer(); } Component comp = renderer.getTableCellRendererComponent(paramsTable, col.getHeaderValue(), false, false, 0, 0); width = comp.getPreferredSize().width; col.setPreferredWidth(width + 2); } paramsTable.getColumnModel().getColumn(6).setPreferredWidth(999); // value }
/** * Returns the number of contained columns. The count includes or excludes * invisible columns, depending on whether the <code>includeHidden</code> is * true or false, respectively. If false, this method returns the same count * as <code>getColumnCount()</code>. If the columnModel is not of type * <code>TableColumnModelExt</code>, the parameter value has no effect. * * @param includeHidden a boolean to indicate whether invisible columns * should be included * @return the number of contained columns, including or excluding the * invisible as specified. * @see #getColumnCount() * @see TableColumnModelExt#getColumnCount(boolean) */ public int getColumnCount(boolean includeHidden) { if (getColumnModel() instanceof TableColumnModelExt) { return ((TableColumnModelExt) getColumnModel()) .getColumnCount(includeHidden); } return getColumnCount(); }