People are wanting to click to minimize the program, the icon is next to the clock. I created a button that does this action. I confess that I did not do it, but the author helped me a lot.
This is code I am using on the button. I wish I could do the same by miming the program to stay by the clock without having to click the button I created.
Thank you in advance!
if (SystemTray.isSupported()) {
final SystemTray systemTray = SystemTray.getSystemTray();
final TrayIcon trayIcon = new TrayIcon(new ImageIcon(icoPath, "omt").getImage(), "QuickStage");
trayIcon.setImageAutoSize(true);// Autosize icon base on space
// Mouse
MouseAdapter mouseAdapter = new MouseAdapter() {
// Exibir
@Override
public void mouseClicked(MouseEvent e) {
systemTray.remove(trayIcon);
main.this.setVisible(true);
}
};
// Ocultar
trayIcon.addMouseListener(mouseAdapter);
try {
systemTray.add(trayIcon);
main.this.setVisible(false);
trayIcon.displayMessage("Aviso!", "QuickStage continua em execução...", TrayIcon.MessageType.INFO);
} catch (Exception e) {
e.printStackTrace();
}
}