3
People are wanting that when clicking to minimize the program, its icon is next to the clock. I created a button that does this action. I confess that I didn’t do it, but the author helped me a lot.
That’s the code I’m using on the button. I wish I could do the same thing mimicking the program to be next to 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();
}
}
Related: Launch my Windows application in System Tray
– Math