本文整理汇总了Java中javax.swing.table.TableColumnModel.addColumn方法的典型用法代码示例。如果您正苦于以下问题:Java TableColumnModel.addColumn方法的具体用法?Java TableColumnModel.addColumn怎么用?Java TableColumnModel.addColumn使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.table.TableColumnModel
的用法示例。
在下文中一共展示了TableColumnModel.addColumn方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: recreateTableColumn
import javax.swing.table.TableColumnModel; //导入方法依赖的package包/类
protected void recreateTableColumn(TableColumnModel columnModel) {
int n = columnModel.getColumnCount();
EditableTableHeaderColumn[] newCols = new EditableTableHeaderColumn[n];
TableColumn[] oldCols = new TableColumn[n];
for (int i = 0; i < n; i++) {
oldCols[i] = columnModel.getColumn(i);
newCols[i] = new EditableTableHeaderColumn(i);
newCols[i].copyValues(oldCols[i]);
}
for (int i = 0; i < n; i++) {
columnModel.removeColumn(oldCols[i]);
}
for (int i = 0; i < n; i++) {
columnModel.addColumn(newCols[i]);
}
}
示例2: getJTableOptions
import javax.swing.table.TableColumnModel; //导入方法依赖的package包/类
public static void getJTableOptions(final String name, final JTable table,
final Properties properties) {
final Integer colCount = getObjectInteger(name + "_col_count",
properties);
if (colCount == null || colCount.intValue() != table.getColumnCount())
return;
final String cNames[] = new String[table.getColumnCount()];
final Object cols[] = new Object[table.getColumnCount()];
for (int i = 0; i < cNames.length; i++) {
cNames[i] = table.getColumnName(i);
cols[i] = table.getColumnModel().getColumn(i);
}
for (final String element : cNames) {
final int width = getInteger(name + "_col_" + element + "_width",
table.getColumn(element).getWidth(), properties);
table.getColumn(element).setPreferredWidth(width);
}
final TableColumnModel cm = table.getColumnModel();
final int tci[] = new int[cNames.length];
for (int i = 0; i < cNames.length; i++)
cm.removeColumn((TableColumn) cols[i]);
for (int i = 0; i < cNames.length; i++) {
tci[i] = getInteger(name + "_col_" + cNames[i] + "_index", i,
properties);
}
for (int i = 0; i < cNames.length; i++)
for (int j = 0; j < cNames.length; j++)
if (tci[j] == i)
cm.addColumn((TableColumn) cols[j]);
}
示例3: getJTableOptions
import javax.swing.table.TableColumnModel; //导入方法依赖的package包/类
public static void getJTableOptions(final String name, final JTable table,
final Properties properties) {
final Integer colCount = getObjectInteger(name + "_col_count",
properties);
if (colCount == null || colCount.intValue() != table.getColumnCount())
return;
final Object cols[] = new Object[table.getColumnCount()];
for (int i = 0; i < colCount.intValue(); i++) {
cols[i] = table.getColumnModel().getColumn(
table.convertColumnIndexToView(i));
}
for (int i = 0; i < colCount.intValue(); i++) {
try {
int index = table.convertColumnIndexToView(i);
final int width = getInteger(name + "_col_" + i + "_width",
table.getColumnModel().getColumn(index).getWidth(),
properties);
table.getColumnModel().getColumn(index)
.setPreferredWidth(width);
} catch (Exception e) {
}
}
final TableColumnModel cm = table.getColumnModel();
final int tci[] = new int[colCount.intValue()];
for (int i = 0; i < colCount.intValue(); i++)
cm.removeColumn((TableColumn) cols[i]);
for (int i = 0; i < colCount.intValue(); i++) {
tci[i] = getInteger(name + "_col_" + i + "_index", i, properties);
}
for (int i = 0; i < colCount.intValue(); i++)
for (int j = 0; j < colCount.intValue(); j++)
if (tci[j] == i)
cm.addColumn((TableColumn) cols[j]);
}