javax.swing.table.TableColumnModel.moveColumn()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(7.7k)|赞(0)|评价(0)|浏览(101)

本文整理了Java中javax.swing.table.TableColumnModel.moveColumn()方法的一些代码示例,展示了TableColumnModel.moveColumn()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TableColumnModel.moveColumn()方法的具体详情如下:
包路径:javax.swing.table.TableColumnModel
类名称:TableColumnModel
方法名:moveColumn

TableColumnModel.moveColumn介绍

暂无

代码示例

代码示例来源:origin: stackoverflow.com

int lastColumn = tcm.getColumnCount() - 1;
if (column < lastColumn) {
  tcm.moveColumn(lastColumn, column);

代码示例来源:origin: stackoverflow.com

int lastColumn = tcm.getColumnCount() - 1;
if (ic.index < lastColumn) {
  tcm.moveColumn(lastColumn, ic.index);

代码示例来源:origin: de.sciss/jtreetable

@Override
public void moveColumn(int columnIndex, int newIndex) {
  delegate.moveColumn(columnIndex, newIndex);
}

代码示例来源:origin: org.netbeans.api/org-openide-explorer

@Override
  public void actionPerformed(java.awt.event.ActionEvent actionEvent) {
    treeTable.getColumnModel().moveColumn(col, col - 1);
  }
}

代码示例来源:origin: org.netbeans.api/org-openide-explorer

@Override
  public void actionPerformed(java.awt.event.ActionEvent actionEvent) {
    treeTable.getColumnModel().moveColumn(col, col + 1);
  }
}

代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/openide

public void actionPerformed(java.awt.event.ActionEvent actionEvent) {
    treeTable.getColumnModel().moveColumn( col, col + 1 );
  }
});

代码示例来源:origin: net.sf.squirrel-sql.thirdpary-non-maven/openide

public void actionPerformed(java.awt.event.ActionEvent actionEvent) {
    treeTable.getColumnModel().moveColumn( col, col + 1 );
  }
});

代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/openide

public void actionPerformed(java.awt.event.ActionEvent actionEvent) {
    treeTable.getColumnModel().moveColumn( col, col - 1 );
  }
});

代码示例来源:origin: net.sf.squirrel-sql.thirdpary-non-maven/openide

public void actionPerformed(java.awt.event.ActionEvent actionEvent) {
    treeTable.getColumnModel().moveColumn( col, col - 1 );
  }
});

代码示例来源:origin: stackoverflow.com

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]));
 }
}

代码示例来源:origin: openpnp/openpnp

/**
   * 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

代码示例来源:origin: net.sf.jt400/jt400

/**
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);
  }
}

代码示例来源:origin: org.appdapter/org.appdapter.lib.gui

/**
 *  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) {
    }
  }
}

代码示例来源:origin: omegat-org/omegat

@Override
public void columnMoved(TableColumnModelEvent e) {
  // Propagate movement to tableTotal
  list.tableTotal.getColumnModel().moveColumn(e.getFromIndex(), e.getToIndex());
}

代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/toniclf

private void setDraggedDistance(int draggedDistance, int column)
  {
    header.setDraggedDistance(draggedDistance);
    if(column!=-1)
    {
      header.getColumnModel().moveColumn(column, column);
    }
  }
}

代码示例来源:origin: tinyMediaManager/tinyMediaManager

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);
  }
 }
}

代码示例来源:origin: com.eas.platypus/platypus-js-grid

/**
 * {@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
  }
}

代码示例来源:origin: com.eas.platypus/platypus-js-grid

/**
 * {@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
    }
  }
}

代码示例来源:origin: xyz.cofe/gui.swing

getColumnModel().moveColumn(idxFrom, vi);
}else{
  TableColumn tc = createTableColumn(columnName);
  int cnt = getColumnModel().getColumnCount();
  if( vi<(cnt-1) ){
    getColumnModel().moveColumn(cnt-1, vi);

代码示例来源:origin: girtel/Net2Plan

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());
  }
}

相关文章