概要
JTable
のソートアイコンを非表示にしたり、別の画像に変更します。
サンプルコード
Icon emptyIcon = new Icon() {
@Override public void paintIcon(Component c, Graphics g, int x, int y) {}
@Override public int getIconWidth(){
return 0;
}
@Override public int getIconHeight() {
return 0;
}
};
UIManager.put("Table.ascendingSortIcon", new IconUIResource(emptyIcon));
UIManager.put("Table.descendingSortIcon", new IconUIResource(emptyIcon));
view all解説
上記のサンプルでは、UIManager
を使用してJTable
のヘッダに表示されるソートアイコンを変更しています。
Default
UIManager.getLookAndFeelDefaults().getIcon("Table.ascendingSortIcon")
などで取得したLookAndFeel
でのデフォルトソートアイコンを表示
Empty
- サイズ
0
のIcon
でソートアイコンを非表示化
- サイズ
Custom
- 透過
png
画像から生成したソートアイコンを表示
- 透過