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


Java TableColumn.setMaxWidth方法代码示例

本文整理汇总了Java中javax.swing.table.TableColumn.setMaxWidth方法的典型用法代码示例。如果您正苦于以下问题:Java TableColumn.setMaxWidth方法的具体用法?Java TableColumn.setMaxWidth怎么用?Java TableColumn.setMaxWidth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.table.TableColumn的用法示例。


在下文中一共展示了TableColumn.setMaxWidth方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: refreshUI

import javax.swing.table.TableColumn; //导入方法依赖的package包/类
private void refreshUI () {
    lToImport.setEnabled (toImport.size () > 0);
    tToImport.setEnabled (toImport.size () > 0);

    lToInstall.setEnabled (toInstall.size () > 0);
    tToInstall.setEnabled (toInstall.size () > 0);

    TableColumn activeColumn = tToImport.getColumnModel ().getColumn (0);
    activeColumn.setMaxWidth (tToImport.getTableHeader ().getHeaderRect (0).width);
    activeColumn = tToInstall.getColumnModel ().getColumn (0);
    activeColumn.setMaxWidth (tToInstall.getTableHeader ().getHeaderRect (0).width);

    if (bImport != null) {
        bImport.setEnabled (checkedToInstall.indexOf (Boolean.TRUE) != -1 || checkedToImport.indexOf (Boolean.TRUE) != -1);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:ImportManager.java

示例2: initColumnWidth

import javax.swing.table.TableColumn; //导入方法依赖的package包/类
/**
 * Initializes preferred (and eventually maximum) width of a table column
 * based on the size of its header and the estimated longest value.
 *
 * @param table Table to adjust the column width for.
 * @param index Index of the column.
 * @param longValue Estimated long value for the column.
 * @param padding Number of pixes for padding.
 */
public static void initColumnWidth(JTable table, int index, Object longValue, int padding) {
    TableColumn column = table.getColumnModel().getColumn(index);

    // get preferred size of the header
    TableCellRenderer headerRenderer = column.getHeaderRenderer();
    if (headerRenderer == null) {
        headerRenderer = table.getTableHeader().getDefaultRenderer();
    }
    Component comp = headerRenderer.getTableCellRendererComponent(
            table, column.getHeaderValue(), false, false, 0, 0);
    int width = comp.getPreferredSize().width;

    // get preferred size of the long value (remeber max of the pref. size for header and long value)
    comp = table.getDefaultRenderer(table.getModel().getColumnClass(index)).getTableCellRendererComponent(
            table, longValue, false, false, 0, index);
    width = Math.max(width, comp.getPreferredSize().width) + 2 * padding;

    // set preferred width of the column
    column.setPreferredWidth(width);
    // if the column contains boolean values, the preferred width
    // should also be its max width
    if (longValue instanceof Boolean) {
        column.setMaxWidth(width);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:35,代码来源:UIUtilities.java

示例3: adjustColumnWidths

import javax.swing.table.TableColumn; //导入方法依赖的package包/类
protected void adjustColumnWidths() {
    TableColumnModel colModel = getColumnModel();
    for( int i=0; i<colModel.getColumnCount(); i++ ) {
        TableColumn tc = colModel.getColumn( i );
        int colWidth = 0;
        for( int row=0; row<getRowCount(); row++ ) {
            colWidth = Math.max( renderer.getPreferredWidth( getValueAt( row, i ) ), colWidth );
        }
        colWidth = Math.max( colWidth, 30 );
        colWidth += getIntercellSpacing().width;
        tc.setWidth( colWidth );
        tc.setMinWidth( colWidth );
        tc.setMaxWidth( colWidth );
        tc.setPreferredWidth( colWidth );
        tc.setResizable( false );
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:TabTable.java

示例4: hideColumn

import javax.swing.table.TableColumn; //导入方法依赖的package包/类
void hideColumn(TableColumn column, ProfilerTable table) {
    hiddenColumnWidths.put(column.getModelIndex(), column.getWidth());
    column.setMinWidth(0);
    column.setMaxWidth(0);
    
    int selected = table.getSelectedColumn();
    if (selected != -1 && getColumn(selected).equals(column)) {
        int newSelected = getPreviousVisibleColumn(selected);
        getSelectionModel().setSelectionInterval(newSelected, newSelected);
    }
            
    if (table.isSortable()) {
        ProfilerRowSorter sorter = table._getRowSorter();
        int sortColumn = sorter.getSortColumn();
        if (sortColumn == column.getModelIndex()) {
            int newSortColumn = table.convertColumnIndexToView(sortColumn);
            newSortColumn = getPreviousVisibleColumn(newSortColumn);
            sorter.setSortColumn(getColumn(newSortColumn).getModelIndex());
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:ProfilerColumnModel.java

示例5: 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

示例6: setColumnWidth

import javax.swing.table.TableColumn; //导入方法依赖的package包/类
/**
 * Sets the appropriate widths for the cells of the table.
 * 
 * @param table
 *            JTable containing the brain.
 */
private void setColumnWidth(JTable table) {
	final int numDirections = CollisionDirection.values().length;
	int[] minimumWidths = new int[numDirections];
	int[] preferredWidths = new int[numDirections];
	int[] maximumWidths = new int[numDirections];
	for (int i = 0; i < numDirections; i++) {
		minimumWidths[i] = 50;
		preferredWidths[i] = 150;
		maximumWidths[i] = 1000;
	}
	minimumWidths = GeneralUtil.concatenate(new int[] { 50, 70 },
			minimumWidths);
	preferredWidths = GeneralUtil.concatenate(new int[] { 40, 200 },
			preferredWidths);
	maximumWidths = GeneralUtil.concatenate(new int[] { 50, 1000 },
			maximumWidths);

	for (int i = 0; i < table.getColumnModel().getColumnCount(); i++) {
		TableColumn column = table.getColumnModel().getColumn(i);
		column.setMinWidth(minimumWidths[i]);
		column.setPreferredWidth(preferredWidths[i]);
		column.setMaxWidth(maximumWidths[i]);
	}
}
 
开发者ID:CognitiveModeling,项目名称:BrainControl,代码行数:31,代码来源:PlayerPanel.java

示例7: 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

示例8: SpringXMLConfigNamespacesVisual

import javax.swing.table.TableColumn; //导入方法依赖的package包/类
public SpringXMLConfigNamespacesVisual() {
        initComponents();
        // set the color of the table's JViewport
        includesTable.getParent().setBackground(includesTable.getBackground());
        TableColumn col1 = includesTable.getColumnModel().getColumn(0);
        col1.setMaxWidth(0);
        includesTable.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
        includesTable.revalidate();
//        springLibrary = SpringUtilities.findSpringLibrary();
    }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:SpringXMLConfigNamespacesVisual.java

示例9: setUpColumns

import javax.swing.table.TableColumn; //导入方法依赖的package包/类
private void setUpColumns(TableColumnModel tcm, int start, int stop) {
    for (int i = start; i <= stop; i++) {
        final TableColumn column = tcm.getColumn(i);
        setUpColumn(column);
        if (i == 0) {
            column.setPreferredWidth(150);
            column.setMaxWidth(150);
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:VMOptionEditorPanel.java

示例10: setColumnWidth

import javax.swing.table.TableColumn; //导入方法依赖的package包/类
private void setColumnWidth(int columnIndex) {
    TableColumn col = jTableFields.getColumnModel().getColumn(columnIndex);
    JCheckBox box = new JCheckBox();
    int width = (int) box.getPreferredSize().getWidth();
    col.setPreferredWidth(width);
    col.setMinWidth(width);
    col.setMaxWidth(width);
    col.setResizable(false);        
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:10,代码来源:EncapsulateFieldPanel.java

示例11: adjustColumnWidths

import javax.swing.table.TableColumn; //导入方法依赖的package包/类
private void adjustColumnWidths( int topColumn ) {
    TableColumnModel colModel = getColumnModel();
    int colWidth = 0;
    int subColWidth = -1;
    for( int row=0; row<getRowCount(); row++ ) {
        Item item = ( Item ) getValueAt( row, topColumn );
        Component ren = prepareRenderer( this.getCellRenderer( row, topColumn ), row, topColumn, item, true );
        int prefWidth = ren.getPreferredSize().width;
        colWidth = Math.max( colWidth, prefWidth );
        
        if( null != item && item.hasSubItems() && topColumn+1 < getColumnCount()
                && !getSwitcherModel().isTopItemColumn( topColumn+1 ) ) {
            Item[] subItems = item.getActivatableSubItems();
            for( int i=0; i<subItems.length; i++ ) {
                ren = prepareRenderer( this.getCellRenderer( 0, topColumn+1 ), 0, topColumn+1, subItems[i], true );
                prefWidth = ren.getPreferredSize().width;
                subColWidth = Math.max( subColWidth, prefWidth );
            }
        }
    }
    colWidth = Math.min( colWidth, MAX_TOP_COLUMN_WIDTH );
    TableColumn tc = colModel.getColumn( topColumn );
    tc.setPreferredWidth( colWidth );
    tc.setWidth( colWidth );
    tc.setMaxWidth( colWidth );

    if( subColWidth > 0 ) {
        subColWidth = Math.min( subColWidth, MAX_SUB_COLUMN_WIDTH );
        tc = colModel.getColumn( topColumn+1 );
        tc.setPreferredWidth( subColWidth );
        tc.setWidth( subColWidth );
        tc.setMaxWidth( subColWidth );
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:35,代码来源:Table.java

示例12: initTable

import javax.swing.table.TableColumn; //导入方法依赖的package包/类
private void initTable() {
	final TableColumn tailleColumn = getColumn(FileTableModel.TAILLE_HEADER);
	tailleColumn.setCellRenderer(new IntegerTableCellRenderer());
	tailleColumn.setMaxWidth(60);
	final TableColumn typeIconColumn = getColumn(FileTableModel.TYPE_ICON_HEADER);
	typeIconColumn.setCellRenderer(new IconTableCellRenderer());
	typeIconColumn.setMaxWidth(30);

	setPreferredScrollableViewportSize(new Dimension(530, 150));
}
 
开发者ID:evernat,项目名称:dead-code-detector,代码行数:11,代码来源:FileTable.java

示例13: setColumnWidths

import javax.swing.table.TableColumn; //导入方法依赖的package包/类
public void setColumnWidths(TableColumn col, int min, int pref, int max)
{
	if (col == null) return;
	col.setMinWidth(min);
	col.setPreferredWidth(pref);
	col.setMaxWidth(max);
}
 
开发者ID:drytoastman,项目名称:scorekeeperfrontend,代码行数:8,代码来源:TableBase.java

示例14: refresh

import javax.swing.table.TableColumn; //导入方法依赖的package包/类
void refresh() {
    clear();
    if (null == currClassFile) return;

    TableColumn thisCol;
    MethodTableModel thisModel = new MethodTableModel(currClassFile);
    thisModel.setEditable(bEditable);
    tblMethodNames.setModel(thisModel);
    thisModel.setCellEditors(tblMethodNames);

    thisCol = tblMethodNames.getColumnModel().getColumn(0);
    thisCol.setPreferredWidth(30);
    thisCol.setMaxWidth(80);

    thisCol = tblMethodNames.getColumnModel().getColumn(1);
    thisCol.setPreferredWidth(200);
    thisCol.setMaxWidth(400);

    thisCol = tblMethodNames.getColumnModel().getColumn(2);
    thisCol.setPreferredWidth(300);
    thisCol.setMaxWidth(400);

    thisCol = tblMethodNames.getColumnModel().getColumn(3);
    thisCol.setPreferredWidth(300);
    thisCol.setMaxWidth(600);

    tblMethodNames.changeSelection(0, 1, false, false);
}
 
开发者ID:dmitrykolesnikovich,项目名称:featurea,代码行数:29,代码来源:MethodsPropPane.java

示例15: init

import javax.swing.table.TableColumn; //导入方法依赖的package包/类
private void init() {
    setOpaque( false );
    getSelectionModel().clearSelection();
    getSelectionModel().setAnchorSelectionIndex(-1);
    getSelectionModel().setLeadSelectionIndex(-1);
    setAutoscrolls( false );
    setShowHorizontalLines(false);
    setShowVerticalLines( false);
    setAutoResizeMode( JTable.AUTO_RESIZE_OFF );
    setTableHeader( null );
    // Calc row height here so that TableModel can adjust number of columns.
    calcRowHeight(getOffscreenGraphics());

    //mouse click into the table performs the switching
    addMouseListener( new MouseAdapter() {
        @Override
        public void mousePressed( MouseEvent e ) {
            int row = rowAtPoint( e.getPoint() );
            int col = columnAtPoint( e.getPoint() );
            if( row >= 0 && col >= 0 ) {
                if( select( row, col ) ) {
                    performSwitching();
                }
            }
        }
    });

    //icon for top-level items with sub-items
    rightArrowLabel.setIcon( new ArrowIcon() );
    rightArrowLabel.setIconTextGap( 2 );
    rightArrowLabel.setHorizontalTextPosition( JLabel.LEFT );
    topItemPanel.setLayout( new BorderLayout(5, 0) );
    topItemPanel.add( rightArrowLabel, BorderLayout.EAST );
    topItemPanel.getAccessibleContext().setAccessibleDescription( NbBundle.getMessage(Table.class, "ACD_OTHER_EDITORS") );
    topItemPanel.setBorder( BorderFactory.createEmptyBorder( 0, 0, 0, 2) );

    //adjust column widths to accomodate the widest item in each column
    for( int col=0; col<getColumnCount(); col++ ) {
        if( getSwitcherModel().isTopItemColumn( col ) )
            adjustColumnWidths( col );
    }

    //include the width of vertical scrollbar if there are too many rows
    int maxRowCount = getSwitcherModel().getMaxRowCount();
    if( maxRowCount > MAX_VISIBLE_ROWS && getRowCount() <= MAX_VISIBLE_ROWS ) {
        JScrollPane scroll = new JScrollPane();
        scroll.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_ALWAYS );
        int scrollWidth = scroll.getVerticalScrollBar().getPreferredSize().width;
        TableColumn tc = getColumnModel().getColumn( getColumnCount()-1 );
        tc.setMaxWidth( tc.getMaxWidth() + scrollWidth );
        tc.setPreferredWidth( tc.getPreferredWidth() + scrollWidth );
        tc.setWidth( tc.getWidth() + scrollWidth );
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:55,代码来源:Table.java


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