javax.swing.JTable.sizeColumnsToFit()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(8.8k)|赞(0)|评价(0)|浏览(162)

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

JTable.sizeColumnsToFit介绍

暂无

代码示例

代码示例来源:origin: camunda/camunda-bpm-platform

public void setDetailedView() {
 //TODO: Defineable Views.
 TableColumnModel model = getColumnModel();
 // Remove all the columns:
 for (int f = 0; f < _numCols; f++) {
  model.removeColumn(_tableColumns[f]);
 }
 // Add them back in the correct order:
 for (int i = 0; i < _numCols; i++) {
  model.addColumn(_tableColumns[i]);
 }
 //SWING BUG:
 sizeColumnsToFit(-1);
}

代码示例来源:origin: camunda/camunda-bpm-platform

public void setView(List columns) {
 TableColumnModel model = getColumnModel();
 // Remove all the columns:
 for (int f = 0; f < _numCols; f++) {
  model.removeColumn(_tableColumns[f]);
 }
 Iterator selectedColumns = columns.iterator();
 Vector columnNameAndNumber = getColumnNameAndNumber();
 while (selectedColumns.hasNext()) {
  // add the column to the view
  model.addColumn(_tableColumns[columnNameAndNumber.indexOf(selectedColumns.next())]);
 }
 //SWING BUG:
 sizeColumnsToFit(-1);
}

代码示例来源:origin: ru.sbtqa/monte-media

public void setModel(StructTableModel model) {
  table.setModel(model);
  table.sizeColumnsToFit(-1);
}

代码示例来源:origin: com.bbossgroups.rpc/bboss-rpc

private void setTableColumnWidths() {
  table.sizeColumnsToFit(JTable.AUTO_RESIZE_NEXT_COLUMN);
  TableColumn column=null;
  column=table.getColumnModel().getColumn(0);
  column.setMinWidth(KEY_COL_WIDTH);
  column.setPreferredWidth(KEY_COL_WIDTH);
  column=table.getColumnModel().getColumn(1);
  column.setPreferredWidth(VAL_COL_WIDTH);
}

代码示例来源:origin: org.jgroups/com.springsource.org.jgroups

private void setTableColumnWidths() {
  table.sizeColumnsToFit(JTable.AUTO_RESIZE_NEXT_COLUMN);
  TableColumn column=null;
  column=table.getColumnModel().getColumn(0);
  column.setMinWidth(KEY_COL_WIDTH);
  column.setPreferredWidth(KEY_COL_WIDTH);
  column=table.getColumnModel().getColumn(1);
  column.setPreferredWidth(VAL_COL_WIDTH);
}

代码示例来源:origin: at.bestsolution.efxclipse.eclipse/org.apache.log4j

public void setView(List columns) {
 TableColumnModel model = getColumnModel();
 // Remove all the columns:
 for (int f = 0; f < _numCols; f++) {
  model.removeColumn(_tableColumns[f]);
 }
 Iterator selectedColumns = columns.iterator();
 Vector columnNameAndNumber = getColumnNameAndNumber();
 while (selectedColumns.hasNext()) {
  // add the column to the view
  model.addColumn(_tableColumns[columnNameAndNumber.indexOf(selectedColumns.next())]);
 }
 //SWING BUG:
 sizeColumnsToFit(-1);
}

代码示例来源:origin: apache-log4j/log4j

public void setView(List columns) {
 TableColumnModel model = getColumnModel();
 // Remove all the columns:
 for (int f = 0; f < _numCols; f++) {
  model.removeColumn(_tableColumns[f]);
 }
 Iterator selectedColumns = columns.iterator();
 Vector columnNameAndNumber = getColumnNameAndNumber();
 while (selectedColumns.hasNext()) {
  // add the column to the view
  model.addColumn(_tableColumns[columnNameAndNumber.indexOf(selectedColumns.next())]);
 }
 //SWING BUG:
 sizeColumnsToFit(-1);
}

代码示例来源:origin: org.apache.log4j/com.springsource.org.apache.log4j

public void setView(List columns) {
 TableColumnModel model = getColumnModel();
 // Remove all the columns:
 for (int f = 0; f < _numCols; f++) {
  model.removeColumn(_tableColumns[f]);
 }
 Iterator selectedColumns = columns.iterator();
 Vector columnNameAndNumber = getColumnNameAndNumber();
 while (selectedColumns.hasNext()) {
  // add the column to the view
  model.addColumn(_tableColumns[columnNameAndNumber.indexOf(selectedColumns.next())]);
 }
 //SWING BUG:
 sizeColumnsToFit(-1);
}

代码示例来源:origin: org.jboss.logmanager/log4j-jboss-logmanager

public void setView(List columns) {
 TableColumnModel model = getColumnModel();
 // Remove all the columns:
 for (int f = 0; f < _numCols; f++) {
  model.removeColumn(_tableColumns[f]);
 }
 Iterator selectedColumns = columns.iterator();
 Vector columnNameAndNumber = getColumnNameAndNumber();
 while (selectedColumns.hasNext()) {
  // add the column to the view
  model.addColumn(_tableColumns[columnNameAndNumber.indexOf(selectedColumns.next())]);
 }
 //SWING BUG:
 sizeColumnsToFit(-1);
}

代码示例来源:origin: org.apache/log4j

public void setView(List columns) {
 TableColumnModel model = getColumnModel();
 // Remove all the columns:
 for (int f = 0; f < _numCols; f++) {
  model.removeColumn(_tableColumns[f]);
 }
 Iterator selectedColumns = columns.iterator();
 Vector columnNameAndNumber = getColumnNameAndNumber();
 while (selectedColumns.hasNext()) {
  // add the column to the view
  model.addColumn(_tableColumns[columnNameAndNumber.indexOf(selectedColumns.next())]);
 }
 //SWING BUG:
 sizeColumnsToFit(-1);
}

代码示例来源:origin: org.apache.log4j/com.springsource.org.apache.log4j

public void setDetailedView() {
 //TODO: Defineable Views.
 TableColumnModel model = getColumnModel();
 // Remove all the columns:
 for (int f = 0; f < _numCols; f++) {
  model.removeColumn(_tableColumns[f]);
 }
 // Add them back in the correct order:
 for (int i = 0; i < _numCols; i++) {
  model.addColumn(_tableColumns[i]);
 }
 //SWING BUG:
 sizeColumnsToFit(-1);
}

代码示例来源:origin: apache-log4j/log4j

public void setDetailedView() {
 //TODO: Defineable Views.
 TableColumnModel model = getColumnModel();
 // Remove all the columns:
 for (int f = 0; f < _numCols; f++) {
  model.removeColumn(_tableColumns[f]);
 }
 // Add them back in the correct order:
 for (int i = 0; i < _numCols; i++) {
  model.addColumn(_tableColumns[i]);
 }
 //SWING BUG:
 sizeColumnsToFit(-1);
}

代码示例来源:origin: Waikato/weka-trunk

/**
 * sets the optimal column width for the given column
 */
public static void setOptimalColumnWidth(JTable jtable, int col) {
 int width;
 TableColumn column;
 JTableHeader header;
 if ((col >= 0) && (col < jtable.getColumnModel().getColumnCount())) {
  width = calcColumnWidth(jtable, col);
  if (width >= 0) {
   header = jtable.getTableHeader();
   column = jtable.getColumnModel().getColumn(col);
   column.setPreferredWidth(width);
   jtable.sizeColumnsToFit(-1);
   header.repaint();
  }
 }
}

代码示例来源:origin: org.jboss.logmanager/log4j-jboss-logmanager

public void setDetailedView() {
 //TODO: Defineable Views.
 TableColumnModel model = getColumnModel();
 // Remove all the columns:
 for (int f = 0; f < _numCols; f++) {
  model.removeColumn(_tableColumns[f]);
 }
 // Add them back in the correct order:
 for (int i = 0; i < _numCols; i++) {
  model.addColumn(_tableColumns[i]);
 }
 //SWING BUG:
 sizeColumnsToFit(-1);
}

代码示例来源:origin: at.bestsolution.efxclipse.eclipse/org.apache.log4j

public void setDetailedView() {
 //TODO: Defineable Views.
 TableColumnModel model = getColumnModel();
 // Remove all the columns:
 for (int f = 0; f < _numCols; f++) {
  model.removeColumn(_tableColumns[f]);
 }
 // Add them back in the correct order:
 for (int i = 0; i < _numCols; i++) {
  model.addColumn(_tableColumns[i]);
 }
 //SWING BUG:
 sizeColumnsToFit(-1);
}

代码示例来源:origin: org.apache/log4j

public void setDetailedView() {
 //TODO: Defineable Views.
 TableColumnModel model = getColumnModel();
 // Remove all the columns:
 for (int f = 0; f < _numCols; f++) {
  model.removeColumn(_tableColumns[f]);
 }
 // Add them back in the correct order:
 for (int i = 0; i < _numCols; i++) {
  model.addColumn(_tableColumns[i]);
 }
 //SWING BUG:
 sizeColumnsToFit(-1);
}

代码示例来源:origin: net.sf.cuf/cuf-swing

/**
 * Show or hide a table column.
 *
 * @param  pModelIndex  column index in the table model
 * @param  pVisible     <code>true</code> to make the column visible
 */
public void setColumnVisible(final int pModelIndex, final boolean pVisible)
{
  if (pVisible)
    showColumn(pModelIndex);
  else
    hideColumn(pModelIndex);
  // will resize one or more of the columns in the table
  // so that the total width of all of the JTable's columns will be equal to the width of the table
  mTable.sizeColumnsToFit(-1);
}

代码示例来源:origin: nz.ac.waikato.cms.weka/weka-stable

/**
 * Sets the instances who's attribute names will be displayed.
 * 
 * @param newInstances the new set of instances
 */
public void setInstances(Instances newInstances) {
 if (m_Model == null) {
  m_Model = new AttributeTableModel(newInstances);
  m_Table.setModel(m_Model);
  TableColumnModel tcm = m_Table.getColumnModel();
  tcm.getColumn(0).setMaxWidth(60);
  tcm.getColumn(1).setMinWidth(100);
 } else {
  m_Model.setInstances(newInstances);
 }
 m_Table.sizeColumnsToFit(-1);
 m_Table.revalidate();
 m_Table.repaint();
}

代码示例来源:origin: uk.org.mygrid.taverna/taverna-core

/**
 * This is overridden to invoke super's implementation, and then,
 * if the receiver is editing a Tree column, the editor's bounds is
 * reset. The reason we have to do this is because JTable doesn't
 * think the table is being edited, as <code>getEditingRow</code> returns
 * -1, and therefore doesn't automatically resize the editor for us.
 */
public void sizeColumnsToFit(int resizingColumn) { 
super.sizeColumnsToFit(resizingColumn);
if (getEditingColumn() != -1 && getColumnClass(editingColumn) ==
  TreeTableModel.class) {
  Rectangle cellRect = getCellRect(realEditingRow(),
           getEditingColumn(), false);
    Component component = getEditorComponent();
  component.setBounds(cellRect);
    component.validate();
}
}

代码示例来源:origin: robo-code/robocode

protected void scrollPaneComponentResized() {
  // This code is not working...
  Dimension scrollPaneExtent = getScrollPane().getViewport().getExtentSize();
  if (tableSize != null && (tableSize.width < scrollPaneExtent.width)) {
    getTable().setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS);
    getTable().setSize(scrollPaneExtent);
    getTable().sizeColumnsToFit(-1);
  } else {
    if (tableSize != null) {
      getTable().setSize(tableSize);
      getTable().sizeColumnsToFit(-1);
    }
    table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
  }
  validate();
  repaint();
}

相关文章

JTable类方法