JTableのソートアイコンを変更
Total: 10315, Today: 1, Yesterday: 0
Posted by aterai at
Last-modified:
Summary
JTableのソートアイコンを非表示にしたり、別の画像に変更します。
Screenshot

Advertisement
Source Code Examples
class EmptyIcon implements Icon {
@Override public void paintIcon(Component c, Graphics g, int x, int y) {
/* Empty icon */
}
@Override public int getIconWidth() {
return 0;
}
@Override public int getIconHeight() {
return 0;
}
}
// ...
UIManager.put("Table.ascendingSortIcon", new IconUIResource(new EmptyIcon()));
UIManager.put("Table.descendingSortIcon", new IconUIResource(new EmptyIcon()));
View in GitHub: Java, KotlinDescription
上記のサンプルでは、UIManagerを使用してJTableのヘッダに表示されるソートアイコンを変更しています。
DefaultUIManager.getLookAndFeelDefaults().getIcon("Table.ascendingSortIcon")などで取得したLookAndFeelでのデフォルトソートアイコンを表示
Empty- サイズ
0のIconでソートアイコンを非表示化
- サイズ
Custom- 透過
png画像から生成したソートアイコンを表示
- 透過