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


Java TableColumn.getWidth方法代码示例

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


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

示例1: getSize

import javax.swing.table.TableColumn; //导入方法依赖的package包/类
/**
 * Get the dimension of this ColumnGroup.
 *
 * @param table the table the header is being rendered in
 * @return the dimension of the ColumnGroup
 */
@SuppressWarnings("unchecked")
public Dimension getSize(JTable table) {
    Component comp = renderer.getTableCellRendererComponent(
            table, getHeaderValue(), false, false, -1, -1);
    int height = comp.getPreferredSize().height;
    int width = 0;
    Iterator iter = v.iterator();
    while (iter.hasNext()) {
        Object obj = iter.next();
        if (obj instanceof TableColumn) {
            TableColumn aColumn = (TableColumn) obj;
            width += aColumn.getWidth();
        } else {
            width += ((ColumnGroup) obj).getSize(table).width;
        }
    }
    return new Dimension(width, height);
}
 
开发者ID:Vitaliy-Yakovchuk,项目名称:ramus,代码行数:25,代码来源:ColumnGroup.java

示例2: createTableColumn

import javax.swing.table.TableColumn; //导入方法依赖的package包/类
TableColumn createTableColumn(int columnIndex) {
    return new TableColumn(columnIndex) {
        public void setWidth(int width) {
            if (getMaxWidth() == 0 && getWidth() == 0) {
                TableColumn c = getPreviousVisibleColumn(this);
                if (refWidth == -1) refWidth = c.getWidth();
                c.setWidth(refWidth + width);
            } else {
                super.setWidth(width);
            }
        }                
    };
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:14,代码来源:ProfilerColumnModel.java

示例3: drawVerticalLines

import javax.swing.table.TableColumn; //导入方法依赖的package包/类
protected void drawVerticalLines(Graphics g, final int rowCount, final int height) {

        g.setColor(ResultSetJXTable.GRID_COLOR);
        TableColumnModel colModel = getColumnModel();
        int x = 0;
        for (int i = 0; i < colModel.getColumnCount(); ++i) {
            TableColumn column = colModel.getColumn(i);
            x += column.getWidth();
            g.drawLine(x - 1, rowCount * rowHeight, x - 1, height);
        }
    }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:JXTableDecorator.java

示例4: copyValues

import javax.swing.table.TableColumn; //导入方法依赖的package包/类
public void copyValues(TableColumn base) {
	modelIndex = base.getModelIndex();
	identifier = base.getIdentifier();
	width = base.getWidth();
	minWidth = base.getMinWidth();
	setPreferredWidth(base.getPreferredWidth());
	maxWidth = base.getMaxWidth();
	headerRenderer = base.getHeaderRenderer();
	headerValue = base.getHeaderValue();
	cellRenderer = base.getCellRenderer();
	cellEditor = base.getCellEditor();
	isResizable = base.getResizable();
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:14,代码来源:EditableTableHeaderColumn.java

示例5: saveSettings

import javax.swing.table.TableColumn; //导入方法依赖的package包/类
private void saveSettings() {
    TableColumnModel columnModel = table.getColumnModel();
    prefs.putInt(id + "-visible-column-count", columnModel.getColumnCount());
    
    for (int i = 0; i < columnModel.getColumnCount(); i++) {
        TableColumn col = columnModel.getColumn(i);

        int idx = col.getModelIndex();
        int width = col.getWidth();
        prefs.putInt(id + "-column-width-" + idx, width);
        prefs.putInt(id + "-column-order-" + i, idx);
    }
}
 
开发者ID:takun2s,项目名称:smile_1.5.0_java7,代码行数:14,代码来源:TableColumnSettings.java

示例6: paintCells

import javax.swing.table.TableColumn; //导入方法依赖的package包/类
/**
    * (copy & paste from BasicTableUI)
    */
   private void paintCells(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);
               if( isFoldingRow( row ) ) {
                   //paint the cell across the whole table
                   cellRect.x = 0;
                   cellRect.width = table.getColumnModel().getTotalColumnWidth()-columnMargin;
                   paintCell( g, cellRect, row, 0 );
               } else {
                   for(int column = cMin; column <= cMax; column++) {
                       aColumn = cm.getColumn(column);
                       columnWidth = aColumn.getWidth();
                       cellRect.width = columnWidth - columnMargin;
                       if (aColumn != draggedColumn) {
                           paintCell(g, cellRect, row, column);
                       }
                       cellRect.x += columnWidth;
                   }
               }
    }
} else {
    for(int row = rMin; row <= rMax; row++) {
               cellRect = table.getCellRect(row, cMin, false);
               if( isFoldingRow( row ) ) {
                   //paint the cell across the whole table
                   cellRect.x = 0;
                   cellRect.width = table.getColumnModel().getTotalColumnWidth()-columnMargin;
                   paintCell( g, cellRect, row, 0 );
               } else {
                   aColumn = cm.getColumn(cMin);
                   if (aColumn != draggedColumn) {
                       columnWidth = aColumn.getWidth();
                       cellRect.width = columnWidth - columnMargin;
                       paintCell(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(g, cellRect, row, column);
                       }
                   }
               }
    }
}

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

// Remove any renderers that may be left in the rendererPane.
rendererPane.removeAll();
   }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:70,代码来源:TaskListTableUI.java

示例7: doLayout

import javax.swing.table.TableColumn; //导入方法依赖的package包/类
public void doLayout() {
    ProfilerColumnModel cModel = _getColumnModel();
    JTableHeader header = getTableHeader();
    TableColumn res = header == null ? null : header.getResizingColumn();
    if (res != null) {
        // Resizing column
        int delta = getWidth() - cModel.getTotalColumnWidth();
        TableColumn next = cModel.getNextVisibleColumn(res);
        if (res == next) {
            res.setWidth(res.getWidth() + delta);
        } else {
            next.setWidth(next.getWidth() + delta);
        }
    } else {
        // Resizing table
        int toResizeIndex = cModel.getFitWidthColumn();
        if (toResizeIndex == -1) {
            super.doLayout();
        } else {
            Enumeration<TableColumn> columns = cModel.getColumns();
            TableColumn toResizeColumn = null;
            int columnsWidth = 0;
            while (columns.hasMoreElements()) {
                TableColumn column = columns.nextElement();
                if (column.getModelIndex() == toResizeIndex) {
                    if (!cModel.isColumnVisible(column)) {
                        super.doLayout();
                        return;
                    }
                    toResizeColumn = column;
                } else {
                    columnsWidth += column.getWidth();
                }
            }
            if (toResizeColumn != null) toResizeColumn.setWidth(getWidth() - columnsWidth);

            // instead of super.doLayout()
            layout();
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:42,代码来源:ProfilerTable.java

示例8: paintCells

import javax.swing.table.TableColumn; //导入方法依赖的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:SunburstApps,项目名称:OpenJSharp,代码行数:54,代码来源:SynthTableUI.java


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