int lastColumn = tcm.getColumnCount() - 1; if (column < lastColumn) { tcm.moveColumn(lastColumn, column);
int lastColumn = tcm.getColumnCount() - 1; if (ic.index < lastColumn) { tcm.moveColumn(lastColumn, ic.index);
@Override public void moveColumn(int columnIndex, int newIndex) { delegate.moveColumn(columnIndex, newIndex); }
@Override public void actionPerformed(java.awt.event.ActionEvent actionEvent) { treeTable.getColumnModel().moveColumn(col, col - 1); } }
@Override public void actionPerformed(java.awt.event.ActionEvent actionEvent) { treeTable.getColumnModel().moveColumn(col, col + 1); } }
public void actionPerformed(java.awt.event.ActionEvent actionEvent) { treeTable.getColumnModel().moveColumn( col, col + 1 ); } });
public void actionPerformed(java.awt.event.ActionEvent actionEvent) { treeTable.getColumnModel().moveColumn( col, col + 1 ); } });
public void actionPerformed(java.awt.event.ActionEvent actionEvent) { treeTable.getColumnModel().moveColumn( col, col - 1 ); } });
public void actionPerformed(java.awt.event.ActionEvent actionEvent) { treeTable.getColumnModel().moveColumn( col, col - 1 ); } });
public static void setColumnOrder(int[] indices, JTable table, TableColumnModel columnModel) { for (int i = 0; i < indices.length; i++) { columnModel.moveColumn(i, table.convertColumnIndexToView(indices[i])); } }
/** * Convenience method to order the table columns of a table. The columns are ordered based on * the column names specified in the array. If the column name is not found then no column is * moved. This means you can specify a null value to preserve the current order of a given * column. * * @param table the table containing the columns to be sorted * @param columnNames an array containing the column names in the order they should be displayed */ public static void reorderColumns(JTable table, Object... columnNames) { TableColumnModel model = table.getColumnModel(); for (int newIndex = 0; newIndex < columnNames.length; newIndex++) { try { Object columnName = columnNames[newIndex]; int index = model.getColumnIndex(columnName); model.moveColumn(index, newIndex); } catch (IllegalArgumentException e) { } } } } // End of Class RXTable
/** Moves the column and heading at columnIndex to newIndex. The old column at columnIndex will now be found at newIndex, the column that used to be at newIndex is shifted left or right to make room. Indices start at 0. @param columnIndex The index of column to be moved. @param newIndex The new index to move the column to. **/ public void moveColumn(int columnIndex, int newIndex) { // Catch errors if index being out of range. try { table_.getColumnModel().moveColumn(columnIndex,newIndex); } catch(Exception e) { Trace.log(Trace.WARNING, "moveColumn() error:" + e); } }
/** * Convenience method to order the table columns of a table. The columns * are ordered based on the column names specified in the array. If the * column name is not found then no column is moved. This means you can * specify a null value to preserve the current order of a given column. * * @param table the table containing the columns to be sorted * @param columnNames an array containing the column names in the * order they should be displayed */ public void reorderColumns(JTable table, Object... columnNames) { TableColumnModel model = table.getColumnModel(); for (int newIndex = 0; newIndex < columnNames.length; newIndex++) { try { Object columnName = columnNames[newIndex]; int index = model.getColumnIndex(columnName); model.moveColumn(index, newIndex); } catch (IllegalArgumentException e) { } } }
@Override public void columnMoved(TableColumnModelEvent e) { // Propagate movement to tableTotal list.tableTotal.getColumnModel().moveColumn(e.getFromIndex(), e.getToIndex()); }
private void setDraggedDistance(int draggedDistance, int column) { header.setDraggedDistance(draggedDistance); if(column!=-1) { header.getColumnModel().moveColumn(column, column); } } }
public void showColumn(Object identifier) { TableColumn tableCloumn = hiddenColumns.remove(identifier); if (tableCloumn != null) { // find the new index to insert int originIndex = indexedColumns.indexOf(tableCloumn); int newIndex = 0; Enumeration<TableColumn> enumeration = columnModel.getColumns(); while (enumeration.hasMoreElements()) { int index = indexedColumns.indexOf((TableColumn) enumeration.nextElement()); if (index > originIndex) { break; } newIndex++; } columnModel.addColumn(tableCloumn); int lastColumn = columnModel.getColumnCount() - 1; if (newIndex < lastColumn) { columnModel.moveColumn(lastColumn, newIndex); } } }
/** * {@inheritDoc} */ @Override public void moveColumn(int oldIndex, int newIndex) { int colCount = getColumnCount(); if (oldIndex >= 0 && oldIndex < colCount && newIndex >= 0 && newIndex < colCount) { int uncOldIndex = constraint.unconstraint(oldIndex); int uncNewIndex = constraint.unconstraint(newIndex); delegate.moveColumn(uncOldIndex, uncNewIndex); // the event will raise by itself } }
/** * {@inheritDoc} */ @Override public void moveColumn(int sourceIndex, int destIndex) { InsetPart sourcePart = inset.toInnerSpace(sourceIndex, delegate.getColumnCount()); InsetPart destPart = inset.toInnerSpace(destIndex, delegate.getColumnCount()); if (sourcePart.getKind() == destPart.getKind()) { if (sourcePart.getKind() == PartKind.BEFORE) { TableColumn destCol = leftInsetColumns.get(destIndex); TableColumn sourceCol = leftInsetColumns.get(sourceIndex); leftInsetColumns.set(destIndex, sourceCol); leftInsetColumns.set(sourceIndex, destCol); fireColumnMoved(sourceIndex, destIndex); } else if (sourcePart.getKind() == PartKind.AFTER) { TableColumn destCol = rightInsetColumns.get(destIndex); TableColumn sourceCol = rightInsetColumns.get(sourceIndex); rightInsetColumns.set(destIndex, sourceCol); rightInsetColumns.set(sourceIndex, destCol); fireColumnMoved(sourceIndex, destIndex); } else { delegate.moveColumn(sourcePart.getValue(), destPart.getValue()); // the event will raise by itself } } }
getColumnModel().moveColumn(idxFrom, vi); }else{ TableColumn tc = createTableColumn(columnName); int cnt = getColumnModel().getColumnCount(); if( vi<(cnt-1) ){ getColumnModel().moveColumn(cnt-1, vi);
private void rearrangeColumns(final int frozenColumns) { TableColumnModel scrollColumnModel = mainTable.getColumnModel(); TableColumnModel lockedColumnModel = fixedTable.getColumnModel(); if (this.frozenColumns < frozenColumns) { /* move columns from scrollable to fixed table */ for (int i = this.frozenColumns; i < frozenColumns; i++) { TableColumn column = scrollColumnModel.getColumn(0); lockedColumnModel.addColumn(column); scrollColumnModel.removeColumn(column); } fixedTable.setPreferredScrollableViewportSize(fixedTable.getPreferredSize()); } else if (this.frozenColumns > frozenColumns) { /* move columns from fixed to scrollable table */ for (int i = frozenColumns; i < this.frozenColumns; i++) { TableColumn column = lockedColumnModel.getColumn(lockedColumnModel.getColumnCount() - 1); scrollColumnModel.addColumn(column); scrollColumnModel.moveColumn(scrollColumnModel.getColumnCount() - 1, 0); lockedColumnModel.removeColumn(column); } fixedTable.setPreferredScrollableViewportSize(fixedTable.getPreferredSize()); } }