當前位置: 首頁>>代碼示例>>Java>>正文


Java DefaultTableColumnModel.getColumn方法代碼示例

本文整理匯總了Java中javax.swing.table.DefaultTableColumnModel.getColumn方法的典型用法代碼示例。如果您正苦於以下問題:Java DefaultTableColumnModel.getColumn方法的具體用法?Java DefaultTableColumnModel.getColumn怎麽用?Java DefaultTableColumnModel.getColumn使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.swing.table.DefaultTableColumnModel的用法示例。


在下文中一共展示了DefaultTableColumnModel.getColumn方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: packColumn

import javax.swing.table.DefaultTableColumnModel; //導入方法依賴的package包/類
private static void packColumn(JTable table, int vColIndex, int margin) {
    DefaultTableColumnModel colModel = (DefaultTableColumnModel) table.
            getColumnModel();
    TableColumn col = colModel.getColumn(vColIndex);
    int width;            // Obtém a largura do cabeçalho da coluna
    TableCellRenderer renderer = col.getHeaderRenderer();
    if (renderer == null) {
        renderer = table.getTableHeader().getDefaultRenderer();
    }
    Component comp = renderer.getTableCellRendererComponent(
            table, col.getHeaderValue(), false, false, 0, 0);
    width = comp.getPreferredSize().width;            // Obtém a largura maxima da coluna de dados
    for (int r = 0; r < table.getRowCount(); r++) {
        renderer = table.getCellRenderer(r, vColIndex);
        comp = renderer.getTableCellRendererComponent(
                table, table.getValueAt(r, vColIndex), false, false, r,
                vColIndex);
        width = Math.max(width, comp.getPreferredSize().width);
    }
    width += 2 * margin;            // Configura a largura
    col.setPreferredWidth(width);
}
 
開發者ID:karlos7,項目名稱:ViolenciaContraMulher,代碼行數:23,代碼來源:FormataTamanhoColunasJTable.java

示例2: autoResizeColWidth

import javax.swing.table.DefaultTableColumnModel; //導入方法依賴的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

示例3: getPreferredAccessionColumnWidth

import javax.swing.table.DefaultTableColumnModel; //導入方法依賴的package包/類
/**
 * Gets the preferred width of the column specified by colIndex. The column
 * will be just wide enough to show the column head and the widest cell in
 * the column. Margin pixels are added to the left and right (resulting in
 * an additional width of 2*margin pixels. Returns null if the max width
 * cannot be set.
 *
 * @param table the table
 * @param colIndex the colum index
 * @param margin the margin to add
 * @return the preferred width of the column
 */
public Integer getPreferredAccessionColumnWidth(JTable table, int colIndex, int margin) {

    DefaultTableColumnModel colModel = (DefaultTableColumnModel) table.getColumnModel();
    TableColumn col = colModel.getColumn(colIndex);

    // get width of column header
    TableCellRenderer renderer = col.getHeaderRenderer();
    if (renderer == null) {
        renderer = table.getTableHeader().getDefaultRenderer();
    }

    Component comp = renderer.getTableCellRendererComponent(table, col.getHeaderValue(), false, false, 0, 0);
    int width = comp.getPreferredSize().width;

    // add margin
    width += 2 * margin;

    return width;
}
 
開發者ID:compomics,項目名稱:compomics-utilities,代碼行數:32,代碼來源:GeneDetailsDialog.java

示例4: setTableColumnWidth

import javax.swing.table.DefaultTableColumnModel; //導入方法依賴的package包/類
/**
 * 要求Byte/FLOP算出結果テーブル列幅を設定する.<br/>
 * 要求Byte/FLOP算出結果テーブルはすべて固定列幅とする
 * @param columnModel		テーブル列モデル
 */
public void setTableColumnWidth(DefaultTableColumnModel columnModel) {
    for (int i=0; i<columnModel.getColumnCount(); i++) {
        // 列取得
        TableColumn column = columnModel.getColumn(i);
        if (HEADER_COLUMNS_PREFERREDWIDTH.length >= i) {
            if (HEADER_COLUMNS_PREFERREDWIDTH[i] >= 0) {
                //column.setMinWidth(HEADER_COLUMNS_PREFERREDWIDTH[i]);
                //column.setMaxWidth(HEADER_COLUMNS_PREFERREDWIDTH[i]);
                column.setPreferredWidth(HEADER_COLUMNS_PREFERREDWIDTH[i]);
                column.setResizable(true);
            }
            else {
                column.setMinWidth(0);
                column.setMaxWidth(0);
                column.setPreferredWidth(0);
                column.setResizable(false);
            }
        }
    }
}
 
開發者ID:K-scope,項目名稱:K-scope,代碼行數:26,代碼來源:RequiredBFModel.java

示例5: setTableColumnWidth

import javax.swing.table.DefaultTableColumnModel; //導入方法依賴的package包/類
/**
 * ブロック演算カウントテーブル列幅を設定する.<br/>
 * 演算カウントテーブルはすべて固定列幅とする
 * @param columnModel		テーブル列モデル
 */
public void setTableColumnWidth(DefaultTableColumnModel columnModel) {
    for (int i=0; i<columnModel.getColumnCount(); i++) {
        // 列取得
        TableColumn column = columnModel.getColumn(i);
        if (HEADER_COLUMNS_PREFERREDWIDTH.length >= i) {
            if (HEADER_COLUMNS_PREFERREDWIDTH[i] >= 0) {
                column.setMinWidth(HEADER_COLUMNS_PREFERREDWIDTH[i]);
                column.setMaxWidth(HEADER_COLUMNS_PREFERREDWIDTH[i]);
                column.setPreferredWidth(HEADER_COLUMNS_PREFERREDWIDTH[i]);
                column.setResizable(false);
            }
            else {
                column.setMinWidth(0);
                column.setMaxWidth(0);
                column.setPreferredWidth(0);
                column.setResizable(false);
            }
        }
    }
}
 
開發者ID:K-scope,項目名稱:K-scope,代碼行數:26,代碼來源:OperandTableModel.java

示例6: setTableColumnWidth

import javax.swing.table.DefaultTableColumnModel; //導入方法依賴的package包/類
/**
 * 列幅を設定する
 * @param columnModel		テーブル列モデル
 */
public void setTableColumnWidth(DefaultTableColumnModel columnModel) {
    for (int i=0; i<columnModel.getColumnCount(); i++) {
        // 列取得
        TableColumn column = columnModel.getColumn(i);
        if (HEADER_COLUMNS_PREFERREDWIDTH.length >= i) {
            if (HEADER_COLUMNS_PREFERREDWIDTH[i] >= 0) {
                column.setPreferredWidth(HEADER_COLUMNS_PREFERREDWIDTH[i]);
            }
            else {
                column.setMinWidth(0);
                column.setMaxWidth(0);
                column.setPreferredWidth(0);
                column.setResizable(false);
            }
        }
        if (HEADER_COLUMNS_MINWIDTH.length >= i) {
            if (HEADER_COLUMNS_MINWIDTH[i] >= 0) {
                column.setMinWidth(HEADER_COLUMNS_MINWIDTH[i]);
            }
        }
    }
}
 
開發者ID:K-scope,項目名稱:K-scope,代碼行數:27,代碼來源:VariableTableModel.java

示例7: setTableColumnWidth

import javax.swing.table.DefaultTableColumnModel; //導入方法依賴的package包/類
/**
 * 列幅を設定する
 * @param columnModel		テーブル列モデル
 */
public void setTableColumnWidth(DefaultTableColumnModel columnModel) {
    boolean[] visibled = getVisibledColumns();
    int[] preferredWidth = getHeaderColumnsPreferredWidth();
    int[] minWidth = getHeaderColumnsMinWidth();
    for (int i=0; i<columnModel.getColumnCount(); i++) {
        // 列取得
        TableColumn column = columnModel.getColumn(i);
        if (preferredWidth.length >= i) {
            if (preferredWidth[i] >= 0 && visibled[i]) {
                column.setPreferredWidth(preferredWidth[i]);
            }
            else {
                column.setMinWidth(0);
                column.setMaxWidth(0);
                column.setPreferredWidth(0);
                column.setResizable(false);
            }
        }
        if (minWidth.length > i) {
            if (minWidth[i] >= 0) {
                column.setMinWidth(minWidth[i]);
            }
        }
    }
}
 
開發者ID:K-scope,項目名稱:K-scope,代碼行數:30,代碼來源:ProfilerTableBaseModel.java

示例8: adjustColumnSizes

import javax.swing.table.DefaultTableColumnModel; //導入方法依賴的package包/類
private void adjustColumnSizes(JTable table, int column, int margin) {
    DefaultTableColumnModel colModel = (DefaultTableColumnModel) table.getColumnModel();
    TableColumn col = colModel.getColumn(column);
    int width;

    TableCellRenderer renderer = col.getHeaderRenderer();
    if (renderer == null) {
        renderer = table.getTableHeader().getDefaultRenderer();
    }

    Component comp = renderer.getTableCellRendererComponent(table, col.getHeaderValue(), false, false, 0, 0);
    width = comp.getPreferredSize().width;

    for (int r = 0; r < table.getRowCount(); r++) {
        renderer = table.getCellRenderer(r, column);
        comp = renderer.getTableCellRendererComponent(table, table.getValueAt(r, column), false, false, r, column);
        int currentWidth = comp.getPreferredSize().width;
        width = Math.max(width, currentWidth);
    }

    width += 2 * margin;

    col.setPreferredWidth(width);
    col.setWidth(width);
}
 
開發者ID:utdrobotchess,項目名稱:chess-game,代碼行數:26,代碼來源:ChessbotInfoPanel.java

示例9: adjustColumnSizes

import javax.swing.table.DefaultTableColumnModel; //導入方法依賴的package包/類
/**
 * Method sets columns width to the widest value
 * @param table
 * @param column
 * @param margin
 */
public static void adjustColumnSizes(JTable table, int column, int margin) {
    DefaultTableColumnModel colModel = (DefaultTableColumnModel) table.getColumnModel();
    TableColumn col = colModel.getColumn(column);
    int width;
    TableCellRenderer renderer = col.getHeaderRenderer();
    if (renderer == null)
        renderer = table.getTableHeader().getDefaultRenderer();
    Component comp = renderer.getTableCellRendererComponent(table, col.getHeaderValue(), false, false, 0, 0);
    width = comp.getPreferredSize().width;
    for (int r = 0; r < table.getRowCount(); ++r) {
        renderer = table.getCellRenderer(r, column);
        comp = renderer.getTableCellRendererComponent(table, table.getValueAt(r, column), false, false, r, column);
        int currentWidth = comp.getPreferredSize().width;
        width = Math.max(width, currentWidth);
    }
    width += 2 * margin;
    col.setPreferredWidth(width);
}
 
開發者ID:vimsh,項目名稱:mafscaling,代碼行數:25,代碼來源:Utils.java

示例10: getPreferredColumnWidth

import javax.swing.table.DefaultTableColumnModel; //導入方法依賴的package包/類
/**
 * Gets the preferred width of the column specified by vColIndex. The column
 * will be just wide enough to show the column head and the widest cell in
 * the column. Margin pixels are added to the left and right (resulting in
 * an additional width of 2*margin pixels.
 *
 * @param table the table
 * @param colIndex the colum index
 * @param margin the margin to add
 * @return the preferred width of the column
 */
public int getPreferredColumnWidth(JTable table, int colIndex, int margin) {

    DefaultTableColumnModel colModel = (DefaultTableColumnModel) table.getColumnModel();
    TableColumn col = colModel.getColumn(colIndex);

    // get width of column header
    TableCellRenderer renderer = col.getHeaderRenderer();
    if (renderer == null) {
        renderer = table.getTableHeader().getDefaultRenderer();
    }

    Component comp = renderer.getTableCellRendererComponent(table, col.getHeaderValue(), false, false, 0, 0);
    int width = comp.getPreferredSize().width;

    // get maximum width of column data
    for (int r = 0; r < table.getRowCount(); r++) {
        renderer = table.getCellRenderer(r, colIndex);
        comp = renderer.getTableCellRendererComponent(
                table, table.getValueAt(r, colIndex), false, false, r, colIndex);
        width = Math.max(width, comp.getPreferredSize().width);
    }

    // add margin
    width += 2 * margin;

    return width;
}
 
開發者ID:compomics,項目名稱:compomics-utilities,代碼行數:39,代碼來源:UtilitiesDemo.java

示例11: adjustColumnSizes

import javax.swing.table.DefaultTableColumnModel; //導入方法依賴的package包/類
private void adjustColumnSizes() {
    final DefaultTableColumnModel colModel = (DefaultTableColumnModel) getColumnModel();
    for (int i = 0; i < getColumnCount(); i++) {
        final TableColumn col = colModel.getColumn(i);
        int width;

        TableCellRenderer renderer = col.getHeaderRenderer();
        if (renderer == null) {
            renderer = getTableHeader().getDefaultRenderer();
        }
        Component comp = renderer.getTableCellRendererComponent(this, col.getHeaderValue(), false, false, 0, 0);
        width = comp.getPreferredSize().width;

        for (int r = 0; r < getRowCount(); r++) {
            renderer = getCellRenderer(r, i);
            comp = renderer.getTableCellRendererComponent(this, this.getValueAt(r, i), false, false, r, i);
            final int currentWidth = comp.getPreferredSize().width;
            width = Math.max(width, currentWidth);
        }

        width += COLUMN_SPACE;

        col.setPreferredWidth(width);
        col.setWidth(width);
        col.setMinWidth(width);
    }
}
 
開發者ID:Telenav,項目名稱:improve-osm-plugin,代碼行數:28,代碼來源:TurnRestrictionTable.java

示例12: packColumn

import javax.swing.table.DefaultTableColumnModel; //導入方法依賴的package包/類
public void packColumn(JTable table, int vColIndex, int margin, boolean fixWidth) {
	// TableModel model = table.getModel();
	DefaultTableColumnModel colModel = (DefaultTableColumnModel) table.getColumnModel();
	TableColumn col = colModel.getColumn(vColIndex);
	int width = 0;
	// Get width of column header
	TableCellRenderer renderer = col.getHeaderRenderer();
	if (renderer == null) {
		renderer = table.getTableHeader().getDefaultRenderer();
	}
	Component comp = renderer.getTableCellRendererComponent(table, col.getHeaderValue(), false,
			false, 0, 0);
	width = comp.getPreferredSize().width;
	// Get maximum width of column data
	for (int r = 0; r < table.getRowCount(); r++) {
		renderer = table.getCellRenderer(r, vColIndex);
		comp = renderer.getTableCellRendererComponent(table, table.getValueAt(r, vColIndex),
				false, false, r, vColIndex);
		width = Math.max(width, comp.getPreferredSize().width);
	}
	// Add margin
	width += 2 * margin;
	// Set the width
	col.setPreferredWidth(width);
	if (fixWidth) {
		col.setMaxWidth(width);
		col.setMinWidth(width);
	}

}
 
開發者ID:apache,項目名稱:incubator-taverna-workbench,代碼行數:31,代碼來源:ReportViewComponent.java

示例13: packColumn

import javax.swing.table.DefaultTableColumnModel; //導入方法依賴的package包/類
public static void packColumn(JTable table, int vColIndex, int margin) {
    TableModel model = table.getModel();
    DefaultTableColumnModel colModel = (DefaultTableColumnModel)table.getColumnModel();
    TableColumn col = colModel.getColumn(vColIndex);
    int width = 0;

    // Get width of column header
    TableCellRenderer renderer = col.getHeaderRenderer();
    if (renderer == null) {
        renderer = table.getTableHeader().getDefaultRenderer();
    }
    Component comp = renderer.getTableCellRendererComponent(
        table, col.getHeaderValue(), false, false, 0, 0);
    width = comp.getPreferredSize().width;

    // Get maximum width of column data
    for (int r=0; r<table.getRowCount(); r++) {
        renderer = table.getCellRenderer(r, vColIndex);
        comp = renderer.getTableCellRendererComponent(
            table, table.getValueAt(r, vColIndex), false, false, r, vColIndex);
        width = Math.max(width, comp.getPreferredSize().width);
    }

    // Add margin
    width += 2*margin;

    // Set the width
    col.setPreferredWidth(width);
}
 
開發者ID:CoEIA,項目名稱:DEM,代碼行數:30,代碼來源:JTableUtil.java

示例14: packColumnWidth

import javax.swing.table.DefaultTableColumnModel; //導入方法依賴的package包/類
/**
 * Packs table column at the specified index to its preferred width.
 *
 * @param table  table to process
 * @param col    column index
 * @param margin column side margin
 */
public static void packColumnWidth ( final JTable table, final int col, final int margin )
{
    final DefaultTableColumnModel columnModel = ( DefaultTableColumnModel ) table.getColumnModel ();
    final TableColumn column = columnModel.getColumn ( col );
    int width;

    // Header renderer
    TableCellRenderer renderer = column.getHeaderRenderer ();
    if ( renderer == null )
    {
        renderer = table.getTableHeader ().getDefaultRenderer ();
    }

    // Header width
    Component comp = renderer.getTableCellRendererComponent ( table, column.getHeaderValue (), false, false, 0, 0 );
    width = comp.getPreferredSize ().width;

    // Cells width
    for ( int r = 0; r < table.getRowCount (); r++ )
    {
        renderer = table.getCellRenderer ( r, col );
        comp = renderer.getTableCellRendererComponent ( table, table.getValueAt ( r, col ), false, false, r, col );
        width = Math.max ( width, comp.getPreferredSize ().width );
    }

    // Margin
    width += 2 * margin;

    // Final values
    column.setPreferredWidth ( width );
    column.setWidth ( width );
}
 
開發者ID:pyros2097,項目名稱:WebLookAndFeelLite,代碼行數:40,代碼來源:SwingUtils.java

示例15: packColumn

import javax.swing.table.DefaultTableColumnModel; //導入方法依賴的package包/類
private static void packColumn(JTable table, int vColIndex, int margin) {
	DefaultTableColumnModel colModel = (DefaultTableColumnModel) table.getColumnModel();
	TableColumn col = colModel.getColumn(vColIndex);
	int width = 0;

	// Get width of column header
	TableCellRenderer renderer = col.getHeaderRenderer();
	if (renderer == null) {
		renderer = table.getTableHeader().getDefaultRenderer();
	}
	Component comp = renderer.getTableCellRendererComponent(table, col.getHeaderValue(), false,
			false, 0, 0);
	width = comp.getPreferredSize().width;

	// Get maximum width of column data
	for (int r = 0; r < table.getRowCount(); r++) {
		renderer = table.getCellRenderer(r, vColIndex);
		comp = renderer.getTableCellRendererComponent(table, table.getValueAt(r, vColIndex),
				false, false, r, vColIndex);
		width = Math.max(width, comp.getPreferredSize().width);
	}

	// Add margin
	width += 2 * margin;

	// Set the width
	col.setPreferredWidth(width);
}
 
開發者ID:warpfork,項目名稱:gitblit,代碼行數:29,代碼來源:Utils.java


注:本文中的javax.swing.table.DefaultTableColumnModel.getColumn方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。