本文整理汇总了Java中javax.swing.table.TableColumnModel.getColumnCount方法的典型用法代码示例。如果您正苦于以下问题:Java TableColumnModel.getColumnCount方法的具体用法?Java TableColumnModel.getColumnCount怎么用?Java TableColumnModel.getColumnCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.table.TableColumnModel
的用法示例。
在下文中一共展示了TableColumnModel.getColumnCount方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setColumnsData
import javax.swing.table.TableColumnModel; //导入方法依赖的package包/类
private void setColumnsData() {
barRenderer = getBarCellRenderer();
TableColumnModel colModel = resTable.getColumnModel();
colModel.getColumn(0).setPreferredWidth(minNamesColumnWidth);
int index;
for (int i = 0; i < colModel.getColumnCount(); i++) {
index = resTableModel.getRealColumn(i);
if (index == 0) {
colModel.getColumn(i).setPreferredWidth(minNamesColumnWidth);
} else {
colModel.getColumn(i).setPreferredWidth(columnWidths[index - 1]);
}
if (index == 1) {
colModel.getColumn(i).setCellRenderer(barRenderer);
} else {
colModel.getColumn(i).setCellRenderer(columnRenderers[index]);
}
}
}
示例2: createDefaultColumnsFromModel
import javax.swing.table.TableColumnModel; //导入方法依赖的package包/类
@Override
public void createDefaultColumnsFromModel() {
TableModel m = getModel();
if( m != null ) {
// Remove any current columns
TableColumnModel cm = getColumnModel();
while( cm.getColumnCount() > 0 ) {
cm.removeColumn( cm.getColumn(0) );
}
// Create new columns from the data model info
for( int i=0; i<m.getColumnCount(); i++ ) {
TableColumn newColumn = new MyTableColumn(i);
if( i == TaskListModel.COL_LOCATION )
newColumn.setCellRenderer( new LeftDotRenderer() );
else if( i != TaskListModel.COL_GROUP )
newColumn.setCellRenderer( new TooltipRenderer() );
addColumn(newColumn);
}
}
}
示例3: setDefaultColumnSize
import javax.swing.table.TableColumnModel; //导入方法依赖的package包/类
private void setDefaultColumnSize() {
int width = table.getWidth();
TableColumnModel columnModel = table.getColumnModel();
if (columns == null || columnModel == null)
return;
if (columnModel.getColumnCount() != columns.length)
return;
for (int i = 0; i < columns.length; i++) {
String col = columns[i];
sorter.setColumnComparator(i, null);
if (col.equals(PropertiesTableModel.COLUMN_NAME_NAME)) {
columnModel.getColumn(i).setPreferredWidth(width * 20 / 100);
} else if (col.equals(PropertiesTableModel.COLUMN_NAME_VALUE)) {
columnModel.getColumn(i).setPreferredWidth(width * 40 / 100);
}
}
}
示例4: 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);
}
}
示例5: paintVerticalLines
import javax.swing.table.TableColumnModel; //导入方法依赖的package包/类
private void paintVerticalLines(Graphics g) {
int height = getHeight();
int viewHeight = view.getHeight();
if (viewHeight >= height) return;
g.setColor(background);
g.fillRect(0, viewHeight, getWidth(), getHeight() - viewHeight);
int cellX = 0;
int cellWidth;
TableColumnModel model = view.getColumnModel();
int columnCount = model.getColumnCount();
g.setColor(DetailsTable.DEFAULT_GRID_COLOR);
for (int i = 0; i < columnCount; i++) {
cellWidth = model.getColumn(i).getWidth();
cellX += cellWidth;
g.drawLine(cellX - 1, viewHeight, cellX - 1, height);
}
}
示例6: 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 );
}
}
示例7: setDefaultColumnSize
import javax.swing.table.TableColumnModel; //导入方法依赖的package包/类
private void setDefaultColumnSize() {
int width = table.getWidth();
TableColumnModel columnModel = table.getColumnModel();
if (columns == null || columnModel == null)
return;
if (columnModel.getColumnCount() != columns.length)
return;
for (int i = 0; i < columns.length; i++) {
String col = columns[i];
if (col.equals(PropertiesTableModel.COLUMN_NAME_NAME)) {
columnModel.getColumn(i).setPreferredWidth(width * 20 / 100);
} else if (col.equals(PropertiesTableModel.COLUMN_NAME_VALUE)) {
columnModel.getColumn(i).setPreferredWidth(width * 40 / 100);
}
}
}
示例8: createHeaderSize
import javax.swing.table.TableColumnModel; //导入方法依赖的package包/类
/**
* Calculate and return the dimension of the header.
*
* @param width Starting width to be used.
* @return Dimension of the header
*/
private Dimension createHeaderSize(long width) {
TableColumnModel columnModel = header.getColumnModel();
width += columnModel.getColumnMargin() * columnModel.getColumnCount();
if (width > Integer.MAX_VALUE) {
width = Integer.MAX_VALUE;
}
return new Dimension((int) width, getHeaderHeight());
}
示例9: viewIndexForColumn
import javax.swing.table.TableColumnModel; //导入方法依赖的package包/类
/**
* (copy & paste from BasicTableUI)
*/
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;
}
示例10: 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;
}
示例11: createDefaultColumnsFromModel
import javax.swing.table.TableColumnModel; //导入方法依赖的package包/类
@Override
public void createDefaultColumnsFromModel() {
TableModel m = getModel();
if (m != null) {
// Remove any current columns
TableColumnModel cm = getColumnModel();
while (cm.getColumnCount() > 0) {
cm.removeColumn(cm.getColumn(0));
}
// Create one column only
TableColumn newColumn = new TableColumn(0);
addColumn(newColumn);
}
}
示例12: findmatch
import javax.swing.table.TableColumnModel; //导入方法依赖的package包/类
private List<IJavaElement> findmatch(ArrayList<IJavaElement> r, PropertyPredicate p) {
JTableHeader header = (JTableHeader) component;
TableColumnModel columnModel = header.getColumnModel();
int col = columnModel.getColumnCount();
for (int i = 0; i < col; i++) {
JTableHeaderItemJavaElement e = new JTableHeaderItemJavaElement(this, i);
if (p.isValid(e)) {
r.add(e);
}
}
return r;
}
示例13: setColumnSizes
import javax.swing.table.TableColumnModel; //导入方法依赖的package包/类
@Override
public void setColumnSizes(TableColumnModelEvent e)
{
TableColumnModel tcm = (TableColumnModel)e.getSource();
int cc = tcm.getColumnCount();
if (cc <= 1) return;
setColumnWidths(tcm.getColumn(0), 40, 60, 75);
setColumnWidths(tcm.getColumn(1), 80, 250, 400);
doLayout();
}
示例14: adjustRenderers
import javax.swing.table.TableColumnModel; //导入方法依赖的package包/类
public void adjustRenderers()
{
TableColumnModel m = getColumnModel();
if (m.getColumnCount() > 1)
adjustSeqRenderer(m.getColumn(0).getWidth());
int newFontSize = adjustFinalRenderer(m.getColumn(m.getColumnCount()-1).getWidth());
setRowHeight((int)(newFontSize*1.5));
}
示例15: viewIndexForColumn
import javax.swing.table.TableColumnModel; //导入方法依赖的package包/类
/**
* Get the view column index of the given table column
*
* @param aColumn
* @return
*/
private int viewIndexForColumn(TableColumn aColumn) {
TableColumnModel cm = TableHeaderUI.this.header.getColumnModel();
for (int column = 0; column < cm.getColumnCount(); column++) {
if (cm.getColumn(column) == aColumn) {
return column;
}
}
return -1;
}