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


Java TableColumnModel.getColumn方法代码示例

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


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

示例1: adjustColumnWidths

import javax.swing.table.TableColumnModel; //导入方法依赖的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

示例2: mouseMoved

import javax.swing.table.TableColumnModel; //导入方法依赖的package包/类
@Override
public void mouseMoved(MouseEvent evt) {
	TableColumn col = null;
	JTableHeader header = (JTableHeader) evt.getSource();
	JTable table = header.getTable();
	TableColumnModel colModel = table.getColumnModel();
	int vColIndex = colModel.getColumnIndexAtX(evt.getX());

	// Return if not clicked on any column header
	if (vColIndex >= 0) {
		col = colModel.getColumn(vColIndex);
	}

	if (col != curCol) {
		header.setToolTipText(tips.get(col));
		curCol = col;
	}
}
 
开发者ID:HOMlab,项目名称:QN-ACTR-Release,代码行数:19,代码来源:ColumnHeaderToolTips.java

示例3: updateTableColumnSizes

import javax.swing.table.TableColumnModel; //导入方法依赖的package包/类
private void updateTableColumnSizes() {
    ETable table = tableView.getTable();
    Font font = tableView.getFont();
    FontMetrics fm = tableView.getFontMetrics(font);
    int maxCharWidth = fm.charWidth('A');
    int editingBorder = 4;
    TableColumnModel columnModel = table.getColumnModel();

    TableColumn nameColumn = columnModel.getColumn(0);
    nameColumn.setPreferredWidth(8 * maxCharWidth + editingBorder); // 8 chars for name

    TableColumn keyColumn = columnModel.getColumn(1);
    // Single char for key (but 3 chars to prevent "..." in column header)
    keyColumn.setPreferredWidth(3 * maxCharWidth + editingBorder);
    keyColumn.setMinWidth(keyColumn.getPreferredWidth());

    TableColumn locationColumn = columnModel.getColumn(2);
    Insets insets = tableView.getBorder().getBorderInsets(tableView);
    int remainingWidth = tableView.getParent().getWidth() - insets.left - insets.right;
    remainingWidth -= 2 * columnModel.getColumnMargin();
    remainingWidth -= nameColumn.getPreferredWidth();
    remainingWidth -= keyColumn.getPreferredWidth();
    locationColumn.setPreferredWidth(remainingWidth); // remaining space for location
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:25,代码来源:BookmarksView.java

示例4: mouseClicked

import javax.swing.table.TableColumnModel; //导入方法依赖的package包/类
@Override
public void mouseClicked(MouseEvent e) {
    JTableHeader header = (JTableHeader) e.getSource();
    JTable table = header.getTable();
    TableColumnModel columnModel = table.getColumnModel();
    int vci = columnModel.getColumnIndexAtX(e.getX());
    int mci = table.convertColumnIndexToModel(vci);
    if (mci == targetColumnIndex) {
        if (SwingUtilities.isLeftMouseButton(e)) {
            TableColumn column = columnModel.getColumn(vci);
            Object v = column.getHeaderValue();
            boolean b = Status.DESELECTED.equals(v);
            TableModel m = table.getModel();
            for (int i = 0; i < m.getRowCount(); i++) {
                m.setValueAt(b, i, mci);
            }
            column.setHeaderValue(b ? Status.SELECTED : Status.DESELECTED);
        } else if (SwingUtilities.isRightMouseButton(e)) {
            if (popupMenu != null) {
                popupMenu.show(table, e.getX(), 0);
            }
        }
    }
}
 
开发者ID:CognizantQAHub,项目名称:Cognizant-Intelligent-Test-Scripter,代码行数:25,代码来源:TableCheckBoxColumn.java

示例5: adjustColumnRatios

import javax.swing.table.TableColumnModel; //导入方法依赖的package包/类
public void adjustColumnRatios()
{
	TableColumnModel m = getColumnModel();
	if (m == null) return;
	TableColumn c;
	int ii;
	for (ii = 0; ii < m.getColumnCount()-1; ii++)
	{
		c = m.getColumn(ii);
		c.setCellRenderer(seqRenderer);
		c.setMinWidth(35);
		c.setPreferredWidth(100);
		c.setMaxWidth(Integer.MAX_VALUE/2);
	}

	if (ii < m.getColumnCount())
	{
		c = m.getColumn(ii);
		c.setCellRenderer(totalRenderer);
		c.setMinWidth(70);
		c.setPreferredWidth(200);
		c.setMaxWidth(Integer.MAX_VALUE);
	}
}
 
开发者ID:drytoastman,项目名称:scorekeeperfrontend,代码行数:25,代码来源:Timer.java

示例6: setColumnEditors

import javax.swing.table.TableColumnModel; //导入方法依赖的package包/类
private void setColumnEditors() {
    TableColumnModel tcm = getColumnModel();
    for (int i = 0; i < columnNames.length; i++) {
        TableColumn tc = tcm.getColumn(i);
        if (isColumnEditable(i)) {
            tc.setCellEditor(valueCellEditor);
        } else {
            tc.setCellEditor(editor);
        }
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:12,代码来源:XMBeanAttributes.java

示例7: adjustColumnWidths

import javax.swing.table.TableColumnModel; //导入方法依赖的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

示例8: populateTableHeaders

import javax.swing.table.TableColumnModel; //导入方法依赖的package包/类
public void populateTableHeaders() {

        final SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
        final Calendar c = Calendar.getInstance();
        c.setTime(masterDate.getTime());

        JTableHeader tableHeader = table.getTableHeader();
        TableColumnModel tableColumnModel = tableHeader.getColumnModel();
        TableColumn tableColumn;

        tableColumn = tableColumnModel.getColumn(0);
        tableColumn.setHeaderValue("ROOM");
        tableColumn = tableColumnModel.getColumn(1);
        tableColumn.setHeaderValue("TYPE");
        tableColumn = tableColumnModel.getColumn(2);
        tableColumn.setHeaderValue("STATUS");

        //start the date from minus 1 to get today date.
        c.add(Calendar.DATE, -1);

        //start the loop from 3 because first 3 columns already 
        //populated up and the loop on 10 to get one week 
        for (int i = 3; i < 10; i++) {
            c.add(Calendar.DATE, 1);
            today = simpleDateFormat.format(c.getTime());
            tableColumn = tableColumnModel.getColumn(i);
            tableColumn.setHeaderValue(today);

            //store dates in special array to use it in bottom
            weekDates[i] = today;
        }

        tableHeader.revalidate();
        tableHeader.repaint();

    }
 
开发者ID:Coder-ACJHP,项目名称:Hotel-Properties-Management-System,代码行数:37,代码来源:Main_Blockade.java

示例9: columnStyle

import javax.swing.table.TableColumnModel; //导入方法依赖的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

示例10: refreshRenderEditorTblSeriesSettings

import javax.swing.table.TableColumnModel; //导入方法依赖的package包/类
/**
 * Refreshes renderer and editors of the series table.
 */
private void refreshRenderEditorTblSeriesSettings() {
	
	TableColumnModel tcm = this.getTblSeriesSettings().getColumnModel();
	
	TableColumn colorColumn = tcm.getColumn(1);
	colorColumn.setCellEditor(this.getCellEditorColor());
	colorColumn.setCellRenderer(this.getCellRenderer4Color());
	
	TableColumn columnWidth = tcm.getColumn(2);
	columnWidth.setCellEditor(this.getCellEditorSpinner());
}
 
开发者ID:EnFlexIT,项目名称:AgentWorkbench,代码行数:15,代码来源:ChartSettingsTab.java

示例11: setColumnWidths

import javax.swing.table.TableColumnModel; //导入方法依赖的package包/类
/**
 * Sets the width of the table columns according to the integer array
 * @param columnWidths Array containing the widths to set
 */
protected void setColumnWidths(Vector<Integer> columnWidths){
	if(columnWidths != null){
		TableColumnModel tcm = this.myJTable.getColumnModel();
		for(int i=0; i<this.getColumnCount() && i<columnWidths.size(); i++){
			TableColumn tc = tcm.getColumn(i);
			tc.setPreferredWidth(columnWidths.get(i));
		}
	}
}
 
开发者ID:EnFlexIT,项目名称:AgentWorkbench,代码行数:14,代码来源:TableModel.java

示例12: getIndexFromHeader

import javax.swing.table.TableColumnModel; //导入方法依赖的package包/类
private int getIndexFromHeader(String selectedHeader) {
    TableColumnModel tcm = tableHeader.getColumnModel();
    if (tcm == null) {
        System.out.println("RTableHeaderTest.getIndexFromHeader() : Unable to get columnModel for table header:");
    }
    for (int i = 0; i < tcm.getColumnCount(); i++) {
        TableColumn tableColumn = tcm.getColumn(i);
        if (tableColumn.getIdentifier().equals(selectedHeader)) {
            return i;
        }
    }
    return -1;
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:14,代码来源:RTableHeaderTest.java

示例13: update

import javax.swing.table.TableColumnModel; //导入方法依赖的package包/类
public void update() {
	((AbstractTableModel) getModel()).fireTableStructureChanged();
	TableColumnModel columnModel = getColumnModel();
	for (int i = 0; i < columnModel.getColumnCount(); i++) {
		TableColumn tableColumn = columnModel.getColumn(i);
		tableColumn.setPreferredWidth(120);
	}
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:9,代码来源:ExampleSourceConfigurationWizardValueTypeTable.java

示例14: viewIndexForColumn

import javax.swing.table.TableColumnModel; //导入方法依赖的package包/类
private int viewIndexForColumn(TableColumn aColumn) {
    TableColumnModel cm = table.getColumnModel();
    for (int column = 0; column < cm.getColumnCount(); column++) {
        if (cm.getColumn(column) == aColumn) {
            return column;
        }
    }
    return -1;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:10,代码来源:SynthTableUI.java

示例15: paintCells

import javax.swing.table.TableColumnModel; //导入方法依赖的package包/类
private void paintCells(SynthContext context, Graphics g, int rMin,
                        int rMax, int cMin, int cMax) {
    JTableHeader header = table.getTableHeader();
    TableColumn draggedColumn = (header == null) ? null : header.getDraggedColumn();

    TableColumnModel cm = table.getColumnModel();
    int columnMargin = cm.getColumnMargin();

    Rectangle cellRect;
    TableColumn aColumn;
    int columnWidth;
    if (table.getComponentOrientation().isLeftToRight()) {
        for(int row = rMin; row <= rMax; row++) {
            cellRect = table.getCellRect(row, cMin, false);
            for(int column = cMin; column <= cMax; column++) {
                aColumn = cm.getColumn(column);
                columnWidth = aColumn.getWidth();
                cellRect.width = columnWidth - columnMargin;
                if (aColumn != draggedColumn) {
                    paintCell(context, g, cellRect, row, column);
                }
                cellRect.x += columnWidth;
            }
        }
    } else {
        for(int row = rMin; row <= rMax; row++) {
            cellRect = table.getCellRect(row, cMin, false);
            aColumn = cm.getColumn(cMin);
            if (aColumn != draggedColumn) {
                columnWidth = aColumn.getWidth();
                cellRect.width = columnWidth - columnMargin;
                paintCell(context, g, cellRect, row, cMin);
            }
            for(int column = cMin+1; column <= cMax; column++) {
                aColumn = cm.getColumn(column);
                columnWidth = aColumn.getWidth();
                cellRect.width = columnWidth - columnMargin;
                cellRect.x -= columnWidth;
                if (aColumn != draggedColumn) {
                    paintCell(context, g, cellRect, row, column);
                }
            }
        }
    }

    // Paint the dragged column if we are dragging.
    if (draggedColumn != null) {
        paintDraggedArea(context, g, rMin, rMax, draggedColumn, header.getDraggedDistance());
    }

    // Remove any renderers that may be left in the rendererPane.
    rendererPane.removeAll();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:54,代码来源:SynthTableUI.java


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