本文整理汇总了Java中javax.swing.JTable.convertColumnIndexToView方法的典型用法代码示例。如果您正苦于以下问题:Java JTable.convertColumnIndexToView方法的具体用法?Java JTable.convertColumnIndexToView怎么用?Java JTable.convertColumnIndexToView使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JTable
的用法示例。
在下文中一共展示了JTable.convertColumnIndexToView方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getIcon
import javax.swing.JTable; //导入方法依赖的package包/类
/**
* Overridden to return an icon suitable to a sorted column, or null if the
* column is unsorted. The icon for the primary sorted column is fully
* opaque, and the opacity is reduced by a factor of
* <code>alpha</code> for each subsequent sort index.
*
* @param table the <code>JTable</code>.
* @param column the column index.
* @return the sort icon with appropriate opacity, or null if the column is
* unsorted.
*/
@Override
public Icon getIcon(JTable table, int column) {
float computedAlpha = 1.0F;
for (RowSorter.SortKey sortKey : table.getRowSorter().getSortKeys()) {
if (table.convertColumnIndexToView(sortKey.getColumn()) == column) {
switch (sortKey.getSortOrder()) {
case ASCENDING:
return new AlphaIcon(UIManager.getIcon("Table.ascendingSortIcon"), computedAlpha);
case DESCENDING:
return new AlphaIcon(UIManager.getIcon("Table.descendingSortIcon"), computedAlpha);
default:
// Just to remove unmatched case warning
}
}
computedAlpha *= alpha;
}
return null;
}
示例2: getIcon
import javax.swing.JTable; //导入方法依赖的package包/类
/**
* Overloaded to return an icon suitable to the primary sorted column, or
* null if the column is not the primary sort key.
*
* @param table the <code>JTable</code>.
* @param column the column index.
* @return the sort icon, or null if the column is unsorted.
*/
protected Icon getIcon(JTable table, int column) {
SortKey sortKey = getSortKey(table, column);
if (sortKey != null && table.convertColumnIndexToView(sortKey.getColumn()) == column) {
switch (sortKey.getSortOrder()) {
case ASCENDING:
return UIManager.getIcon("Table.ascendingSortIcon");
case DESCENDING:
return UIManager.getIcon("Table.descendingSortIcon");
default:
// Just to remove unmatched case warning
}
}
return null;
}
示例3: setJTableOptions
import javax.swing.JTable; //导入方法依赖的package包/类
public static void setJTableOptions(final String name, final JTable table,
final Properties properties) {
setInteger(name + "_col_count", table.getColumnCount(), properties);
for (int i = 0; i < table.getColumnCount(); i++) {
try {
int index = table.convertColumnIndexToView(i);
setInteger(name + "_col_" + i + "_width", table
.getColumnModel().getColumn(index).getWidth(),
properties);
setInteger(name + "_col_" + i + "_index", index, properties);
} catch (final Exception e) {
}
}
}
示例4: getJTableOptions
import javax.swing.JTable; //导入方法依赖的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]);
}