// //


さらに別のものをって訳でもないけど、表面的機能を試行錯誤。


通常ウィンドウを最小化したとき、アイコン化させタスクトレイへ
その後、アイコンをダブルクリックしてウィンドウが最小化された状態から通常の状態に戻す。
この流れで最小化している時のみアイコンを表示するように弄っているけど…

省略:〜


〜
クラス名{
フィールド
〜
	SystemTray tray = SystemTray.getSystemTray();
	TrayIcon icon = new TrayIcon(ImageIO.read(new File("icon.png")));
〜
	コンストラクタ名{
	〜
		icon.addActionListener(this);
		this.addWindowListener(new WindowListener());
	〜
	}
	public void actionPerformed(ActionEvent e){
		if(e.getSource() == icon){
			setExtendedState(Frame.NORMAL);
			setAlwaysOnTop(true);
			setVisible(true);
			setAlwaysOnTop(false);
			tray.remove(icon);
		}
	〜
	}
	class WindowListener extends WindowAdapter{
		public void windowDeiconified(WindowEvent we){
	〜
	}
〜
}


としていたけど、最小化やその他機能でWindowListener使っているのでそっちに合わせようと

省略:〜

〜
クラス名{
フィールド
〜
	WindowListener wl = new WindowListener();
	SystemTray tray = SystemTray.getSystemTray();
	TrayIcon icon = new TrayIcon(ImageIO.read(new File("icon.png")));
〜
}
	コンストラクタ名{
	〜
		icon.addActionListener(this);
		this.addWindowListener(new WindowListener());
	〜
	}
	public void actionPerformed(ActionEvent e){
		if(e.getSource() == icon){
			wl.windowDeiconified(null);
		}
	〜
	}
	class WindowListener extends WindowAdapter{
		public void windowDeiconified(WindowEvent we){
			setExtendedState(Frame.NORMAL);
			setAlwaysOnTop(true);
			setVisible(true);
			setAlwaysOnTop(false);
			tray.remove(icon);
		}
	〜
	}
〜


としてみた。
上のコードと同じように機能するからいいんだろうけど…
下のコードになにか不安があるんだが…大丈夫だろうか?
…null?


とりあえず勉強になるからいいけど、そろそろ中身に手を出して形にしたい。
と、モチベーション維持のための日記…