---
category: swing
folder: TableSortIcon
title: JTableのソートアイコンを変更
tags: [JTable, JTableHeader, Icon, UIManager]
author: aterai
pubdate: 2008-07-07T11:40:12+09:00
description: JTableのソートアイコンを非表示にしたり、別の画像に変更します。
image: https://lh6.googleusercontent.com/_9Z4BYR88imo/TQTUsaUYVkI/AAAAAAAAAmc/34Qz14LqOGc/s800/TableSortIcon.png
---
* 概要 [#summary]
`JTable`のソートアイコンを非表示にしたり、別の画像に変更します。

#download(https://lh6.googleusercontent.com/_9Z4BYR88imo/TQTUsaUYVkI/AAAAAAAAAmc/34Qz14LqOGc/s800/TableSortIcon.png)

* サンプルコード [#sourcecode]
#code(link){{
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));
}}

* 解説 [#explanation]
上記のサンプルでは、`UIManager`を使用して`JTable`のヘッダに表示されるソートアイコンを変更しています。

- サイズ`0`の`Icon`でソートアイコンを非表示
- 透過`png`画像から生成したソートアイコンを表示

//* 参考リンク [#reference]
* コメント [#comment]
#comment
#comment