当前位置: 首页>>代码示例>>Java>>正文


Java TableColumn.setPreferredWidth方法代码示例

本文整理汇总了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);
}
 
开发者ID:dmitrykolesnikovich,项目名称:featurea,代码行数:22,代码来源:CodeAttribPane.java

示例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;
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:KeymapPanel.java

示例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);
}
 
开发者ID:dmitrykolesnikovich,项目名称:featurea,代码行数:24,代码来源:LocalVariableAttribPane.java

示例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;
}
 
开发者ID:Hitachi-Data-Systems,项目名称:Open-DM,代码行数:24,代码来源:GUIHelper.java

示例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);
        }
    }
 
开发者ID:tiweGH,项目名称:OpenDiabetes,代码行数:36,代码来源:GridSwing.java

示例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);
}
 
开发者ID:max6cn,项目名称:jmt,代码行数:21,代码来源:GraphPanel.java

示例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);
}
 
开发者ID:drytoastman,项目名称:scorekeeperfrontend,代码行数:10,代码来源:ResultsPane.java

示例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));
	}
}
 
开发者ID:OpenDA-Association,项目名称:OpenDA,代码行数:34,代码来源:CorrelationTableController.java

示例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);
}
 
开发者ID:dmitrykolesnikovich,项目名称:featurea,代码行数:16,代码来源:CodeAttribPane.java

示例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;
}
 
开发者ID:meteoorkip,项目名称:JavaGraph,代码行数:10,代码来源:LibrariesTable.java

示例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);

}
 
开发者ID:NBANDROIDTEAM,项目名称:NBANDROID-V2,代码行数:29,代码来源:LogTableManager.java

示例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);                
        }
    }
}
 
开发者ID:ser316asu,项目名称:SER316-Ingolstadt,代码行数:14,代码来源:ProjectsTablePanel.java

示例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));
	}
}
 
开发者ID:OpenDA-Association,项目名称:OpenDA,代码行数:34,代码来源:VariationPerParameterTableController.java

示例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);                
        }
    }
}
 
开发者ID:ser316asu,项目名称:SER316-Munich,代码行数:16,代码来源:ProjectsTablePanel.java

示例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);        
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:8,代码来源:FmtImports.java


注:本文中的javax.swing.table.TableColumn.setPreferredWidth方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。