本文整理汇总了Java中javax.swing.table.TableColumn.setPreferredWidth方法的典型用法代码示例。如果您正苦于以下问题:Java TableColumn.setPreferredWidth方法的具体用法?Java TableColumn.setPreferredWidth怎么用?Java TableColumn.setPreferredWidth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.table.TableColumn
的用法示例。
在下文中一共展示了TableColumn.setPreferredWidth方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setExceptionTableModel
import javax.swing.table.TableColumn; //导入方法依赖的package包/类
private void setExceptionTableModel() {
CodeExceptionsListTableModel localCodeExceptionsListTableModel = new CodeExceptionsListTableModel(this.constPool, this.attribute);
this.tblExceptions.setModel(localCodeExceptionsListTableModel);
localCodeExceptionsListTableModel.setEditable(this.bModifyMode);
localCodeExceptionsListTableModel.setCellEditors(this.tblExceptions);
TableColumn localTableColumn = this.tblExceptions.getColumnModel().getColumn(0);
localTableColumn.setPreferredWidth(30);
localTableColumn.setMaxWidth(80);
localTableColumn = this.tblExceptions.getColumnModel().getColumn(1);
localTableColumn.setPreferredWidth(300);
localTableColumn.setMaxWidth(500);
localTableColumn = this.tblExceptions.getColumnModel().getColumn(2);
localTableColumn.setPreferredWidth(100);
localTableColumn.setMaxWidth(150);
localTableColumn = this.tblExceptions.getColumnModel().getColumn(3);
localTableColumn.setPreferredWidth(100);
localTableColumn.setMaxWidth(150);
localTableColumn = this.tblExceptions.getColumnModel().getColumn(4);
localTableColumn.setPreferredWidth(100);
localTableColumn.setMaxWidth(150);
}
示例2: setColumnWidths
import javax.swing.table.TableColumn; //导入方法依赖的package包/类
/**
* Adjust column widths
*/
private void setColumnWidths() {
TableColumn column = null;
for (int i = 0; i < actionsTable.getColumnCount(); i++) {
column = actionsTable.getColumnModel().getColumn(i);
switch (i) {
case 0:
column.setPreferredWidth(250);
break;
case 1:
column.setPreferredWidth(175);
break;
case 2:
column.setPreferredWidth(60);
break;
case 3:
column.setPreferredWidth(60);
break;
}
}
}
示例3: setTableModel
import javax.swing.table.TableColumn; //导入方法依赖的package包/类
private void setTableModel() {
LocalVariableTableAttribTableModel localLocalVariableTableAttribTableModel = new LocalVariableTableAttribTableModel(this.attribute, this.constPool);
checkForObfuscation();
localLocalVariableTableAttribTableModel.setEditable(this.bModifyMode);
this.tblLocalVariables.setModel(localLocalVariableTableAttribTableModel);
localLocalVariableTableAttribTableModel.setCellEditors(this.tblLocalVariables);
TableColumn localTableColumn = this.tblLocalVariables.getColumnModel().getColumn(0);
localTableColumn.setPreferredWidth(30);
localTableColumn.setMaxWidth(80);
localTableColumn = this.tblLocalVariables.getColumnModel().getColumn(1);
localTableColumn.setPreferredWidth(200);
localTableColumn.setMaxWidth(400);
localTableColumn = this.tblLocalVariables.getColumnModel().getColumn(2);
localTableColumn.setPreferredWidth(200);
localTableColumn.setMaxWidth(400);
localTableColumn = this.tblLocalVariables.getColumnModel().getColumn(3);
localTableColumn.setPreferredWidth(50);
localTableColumn.setMaxWidth(200);
localTableColumn = this.tblLocalVariables.getColumnModel().getColumn(4);
localTableColumn.setPreferredWidth(50);
localTableColumn.setMaxWidth(200);
this.tblLocalVariables.changeSelection(0, 1, false, false);
}
示例4: autoResizeColWidth
import javax.swing.table.TableColumn; //导入方法依赖的package包/类
public static JTable autoResizeColWidth(JTable table, int extraSpaceToColumn) {
if (extraSpaceToColumn < 0 || extraSpaceToColumn >= table.getColumnCount()) {
throw new IllegalArgumentException("Illegal Column index. Table " + table.getName()
+ " has " + table.getColumnCount()
+ " columns. Can't set extra space to column " + extraSpaceToColumn);
}
int totalWidth = autoResizeColWidthNoFill(table);
int availableWidth = table.getParent().getWidth();
if (totalWidth >= availableWidth) {
return table;
}
int increaseBy = availableWidth - totalWidth;
DefaultTableColumnModel colModel = (DefaultTableColumnModel) table.getColumnModel();
TableColumn col = colModel.getColumn(extraSpaceToColumn);
int oldWidth = col.getPreferredWidth();
col.setPreferredWidth(oldWidth + increaseBy);
return table;
}
示例5: autoSizeTableColumns
import javax.swing.table.TableColumn; //导入方法依赖的package包/类
public static void autoSizeTableColumns(JTable table) {
TableModel model = table.getModel();
TableColumn column = null;
Component comp = null;
int headerWidth = 0;
int maxCellWidth = Integer.MIN_VALUE;
int cellWidth = 0;
TableCellRenderer headerRenderer =
table.getTableHeader().getDefaultRenderer();
for (int i = 0; i < table.getColumnCount(); i++) {
column = table.getColumnModel().getColumn(i);
comp = headerRenderer.getTableCellRendererComponent(table,
column.getHeaderValue(), false, false, 0, 0);
headerWidth = comp.getPreferredSize().width + 10;
maxCellWidth = Integer.MIN_VALUE;
for (int j = 0; j < Math.min(model.getRowCount(), 30); j++) {
TableCellRenderer r = table.getCellRenderer(j, i);
comp = r.getTableCellRendererComponent(table,
model.getValueAt(j, i),
false, false, j, i);
cellWidth = comp.getPreferredSize().width;
if (cellWidth >= maxCellWidth) {
maxCellWidth = cellWidth;
}
}
column.setPreferredWidth(Math.max(headerWidth, maxCellWidth)
+ 10);
}
}
示例6: columnAdded
import javax.swing.table.TableColumn; //导入方法依赖的package包/类
@Override
public void columnAdded(TableColumnModelEvent e) {
LinesTableColumn type = getColumnType(e.getToIndex());
TableColumn column = getColumnModel().getColumn(e.getToIndex());
switch (type) {
case COLOR:
column.setMaxWidth(25);
break;
case CLASS:
column.setPreferredWidth(90);
break;
case STATION:
column.setPreferredWidth(90);
break;
case ALGORITHM:
column.setPreferredWidth(100);
break;
}
super.columnAdded(e);
}
示例7: columnStyle
import javax.swing.table.TableColumn; //导入方法依赖的package包/类
protected void columnStyle(TableColumnModel tcm, int column, int min, int mid, int max, TableCellRenderer rend)
{
TableColumn tc = tcm.getColumn(column);
if (tc == null) return;
tc.setMinWidth(min);
tc.setPreferredWidth(mid);
tc.setMaxWidth(max);
tc.setCellRenderer(rend);
}
示例8: initColumnSizes
import javax.swing.table.TableColumn; //导入方法依赖的package包/类
/**
* This method picks good column sizes. If all column headers are wider than
* the column's cells' contents, then just use column.sizeWidthToFit().
* @param table The correlation table
*/
public void initColumnSizes(JTable table) {
TableColumn column;
Component comp;
int headerWidth;
int cellWidth;
TableCellRenderer headerRenderer = table.getTableHeader()
.getDefaultRenderer();
// TODO: move to tableModel. AK
for (int i = 0; i < this.correlationTableModel.getColumnCount(); i++) {
column = table.getColumnModel().getColumn(i);
comp = headerRenderer.getTableCellRendererComponent(null, column
.getHeaderValue(), false, false, 0, 0);
headerWidth = comp.getPreferredSize().width;
// /TODO: move to tableModel. AK
comp = table.getDefaultRenderer(this.correlationTableModel.getColumnClass(i))
.getTableCellRendererComponent(table, this.correlationTableModel.longValues[i], false,
false, 0, i);
cellWidth = comp.getPreferredSize().width;
// XXX: Before Swing 1.1 Beta 2, use setMinWidth instead.
column.setPreferredWidth(Math.max(headerWidth, cellWidth));
}
}
示例9: setInstructionsTableModel
import javax.swing.table.TableColumn; //导入方法依赖的package包/类
private void setInstructionsTableModel() {
InstructionsTableModel localInstructionsTableModel = new InstructionsTableModel(this.constPool, this.attribute.code);
this.tblInstr.setModel(localInstructionsTableModel);
localInstructionsTableModel.setEditable(this.bModifyMode);
localInstructionsTableModel.setCellEditors(this.tblExceptions);
TableColumn localTableColumn = this.tblInstr.getColumnModel().getColumn(0);
localTableColumn.setPreferredWidth(60);
localTableColumn.setMaxWidth(150);
localTableColumn = this.tblInstr.getColumnModel().getColumn(1);
localTableColumn.setPreferredWidth(60);
localTableColumn.setMaxWidth(150);
localTableColumn = this.tblInstr.getColumnModel().getColumn(2);
localTableColumn.setPreferredWidth(500);
localTableColumn.setMaxWidth(800);
}
示例10: prepareRenderer
import javax.swing.table.TableColumn; //导入方法依赖的package包/类
@Override
public Component prepareRenderer(TableCellRenderer renderer, int rowIx, int colIx) {
Component result = super.prepareRenderer(renderer, rowIx, colIx);
// Set the preferred width to at least the width of the cell
TableColumn col = getColumnModel().getColumn(colIx);
col.setPreferredWidth(Math.max(result.getPreferredSize().width, col.getPreferredWidth()));
return result;
}
示例11: initTable
import javax.swing.table.TableColumn; //导入方法依赖的package包/类
private void initTable() {
TableColumn tagColumn = columnModel.getColumn(LogTableModel.COL_TAG);
TableColumn pidColumn = columnModel.getColumn(LogTableModel.COL_PID);
TableColumn pNameColumn = columnModel.getColumn(LogTableModel.COL_PROCESS);
TableColumn timeColumn = columnModel.getColumn(LogTableModel.COL_TIME);
TableColumn levelColumn = columnModel.getColumn(LogTableModel.COL_LEVEL);
tagColumn.setMinWidth(50);
tagColumn.setPreferredWidth(150);
tagColumn.setMaxWidth(300);
pidColumn.setMinWidth(35);
pidColumn.setPreferredWidth(50);
pidColumn.setMaxWidth(70);
pNameColumn.setMinWidth(60);
pNameColumn.setPreferredWidth(80);
pNameColumn.setMaxWidth(300);
timeColumn.setMinWidth(60);
timeColumn.setPreferredWidth(80);
timeColumn.setMaxWidth(120);
levelColumn.setMinWidth(20);
levelColumn.setPreferredWidth(80);
levelColumn.setMaxWidth(80);
}
示例12: initProjectsTable
import javax.swing.table.TableColumn; //导入方法依赖的package包/类
void initProjectsTable() {
projectsTable.setModel(new PrjTableModel());
for (int i = 0; i < 4; i++) {
TableColumn column = projectsTable.getColumnModel().getColumn(i);
if (i == 0) {
column.setPreferredWidth(32767);
}
else {
column.setMinWidth(80);
column.setPreferredWidth(80);
}
}
}
示例13: initColumnSizes
import javax.swing.table.TableColumn; //导入方法依赖的package包/类
/**
* This method picks good column sizes. If all column headers are wider than
* the column's cells' contents, then just use column.sizeWidthToFit().
* @param table JTable
*/
public void initColumnSizes(JTable table) {
TableColumn column;
Component comp;
int headerWidth;
int cellWidth;
TableCellRenderer headerRenderer = table.getTableHeader()
.getDefaultRenderer();
// TODO: move to tableModel. AK
for (int i = 0; i < this.variationPerParameterTableModel.getColumnCount(); i++) {
column = table.getColumnModel().getColumn(i);
comp = headerRenderer.getTableCellRendererComponent(null, column
.getHeaderValue(), false, false, 0, 0);
headerWidth = comp.getPreferredSize().width;
// /TODO: move to tableModel. AK
comp = table.getDefaultRenderer(this.variationPerParameterTableModel.getColumnClass(i))
.getTableCellRendererComponent(table, this.variationPerParameterTableModel.longValues[i], false,
false, 0, i);
cellWidth = comp.getPreferredSize().width;
// XXX: Before Swing 1.1 Beta 2, use setMinWidth instead.
column.setPreferredWidth(Math.max(headerWidth, cellWidth));
}
}
示例14: initProjectsTable
import javax.swing.table.TableColumn; //导入方法依赖的package包/类
void initProjectsTable() {
projectsTable.setModel(new PrjTableModel());
projectsTable.setAutoCreateRowSorter(true);
for (int i = 0; i < 4; i++) {
TableColumn column = projectsTable.getColumnModel().getColumn(i);
if (i == 0) {
column.setPreferredWidth(100);
}
else {
column.setMinWidth(80);
column.setPreferredWidth(80);
}
}
}
示例15: setStarImportPackagesTableColumnsWidth
import javax.swing.table.TableColumn; //导入方法依赖的package包/类
private void setStarImportPackagesTableColumnsWidth() {
int tableWidth = starImportPackagesTable.getPreferredSize().width;
TableColumn column = starImportPackagesTable.getColumnModel().getColumn(1);
int colWidth = starImportPackagesTable.getTableHeader().getDefaultRenderer().getTableCellRendererComponent(starImportPackagesTable, column.getHeaderValue(), false, false, 0, 0).getPreferredSize().width;
column.setPreferredWidth(colWidth);
starImportPackagesTable.getColumnModel().getColumn(0).setPreferredWidth(tableWidth - colWidth);
}