これは、トレイのウィンドウを非表示/開く方法の小さなサンプルです。
import java.awt.Image;
import java.awt.SystemTray;
import java.awt.Toolkit;
import java.awt.TrayIcon;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.JFrame;
public class Test {
public static void main(String[] args) throws Exception {
final JFrame frm = new JFrame("Test");
Image im = Toolkit.getDefaultToolkit().getImage("c:\\icons\\icon1.png");
final TrayIcon tri = new TrayIcon(im);
tri.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
frm.setVisible(true);
try {
SystemTray.getSystemTray().remove(tri);
} catch (Exception ex) {
ex.printStackTrace();
}
}
});
frm.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
try {
SystemTray.getSystemTray().add(tri);
} catch (Exception ex) {
ex.printStackTrace();
}
frm.setVisible(false);
}
});
frm.setSize(100, 100);
frm.setVisible(true);
}
}