JInternalFrameのタイトルバーに表示されるアイコンを変更する
Total: 3107
, Today: 1
, Yesterday: 0
Posted by aterai at
Last-modified:
概要
JInternalFrame
のタイトルバー左上隅に表示されるアイコンを各JInternalFrame
毎に設定します。
サンプルコード
int idx = 0;
for (Color c: Arrays.asList(Color.RED, Color.GREEN, Color.BLUE)) {
String title = String.format("Document #%s", ++idx);
JInternalFrame f = new JInternalFrame(title, true, true, true, true);
desktop.add(f);
f.setFrameIcon(new ColorIcon(c));
f.setSize(240, 120);
f.setLocation(10 + 20 * idx, 20 * idx);
f.setVisible(true);
}
View in GitHub: Java, Kotlin解説
上記のサンプルでは、JInternalFrame#setFrameIcon(Icon)
メソッドを使用して、各JInternalFrame
に異なる色の16x16
アイコンを設定しています。
WindowsLookAndFeel
- アイコン化したとき
JInternalFrame#setFrameIcon(Icon)
で設定したIcon
を拡大した画像がJInternalFrame.JDesktopIcon
として使用される
- アイコン化したとき
MotifLookAndFeel
JInternalFrame#setFrameIcon(Icon)
で設定したアイコンは表示されない(デフォルトアイコンも表示しない)