本文整理匯總了Java中javax.swing.table.TableModel.getColumnName方法的典型用法代碼示例。如果您正苦於以下問題:Java TableModel.getColumnName方法的具體用法?Java TableModel.getColumnName怎麽用?Java TableModel.getColumnName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.swing.table.TableModel
的用法示例。
在下文中一共展示了TableModel.getColumnName方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: setModel
import javax.swing.table.TableModel; //導入方法依賴的package包/類
@Override
public void setModel(final TableModel model) {
boolean shouldSort = this.sortable && checkIfSortable(model);
if (shouldSort) {
this.tableSorter = new ExtendedJTableSorterModel(model);
this.tableSorter.setTableHeader(getTableHeader());
super.setModel(this.tableSorter);
} else {
super.setModel(model);
this.tableSorter = null;
}
originalOrder = new String[model.getColumnCount()];
for (int c = 0; c < model.getColumnCount(); c++) {
originalOrder[c] = model.getColumnName(c);
}
// initializing arrays for cell renderer settings
cutOnLineBreaks = new boolean[model.getColumnCount()];
maximalTextLengths = new int[model.getColumnCount()];
Arrays.fill(maximalTextLengths, Integer.MAX_VALUE);
model.addTableModelListener(new TableModelListener() {
@Override
public void tableChanged(final TableModelEvent e) {
int oldLength = cutOnLineBreaks.length;
if (oldLength != model.getColumnCount()) {
cutOnLineBreaks = Arrays.copyOf(cutOnLineBreaks, model.getColumnCount());
maximalTextLengths = Arrays.copyOf(maximalTextLengths, model.getColumnCount());
if (oldLength < cutOnLineBreaks.length) {
Arrays.fill(cutOnLineBreaks, oldLength, cutOnLineBreaks.length, false);
Arrays.fill(maximalTextLengths, oldLength, cutOnLineBreaks.length, Integer.MAX_VALUE);
}
}
}
});
}