當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。