I have a program in java
, with no graphical interface, only console. The only output commands are System.out.println()
.
I implemented it so that the program had a trayicon. The problem is that I just want the active trayicon when executing and is currently executing tray + console.
I tried, but to no avail:
Runnable runner = new Runnable() {
public void run() {
if (SystemTray.isSupported()) {
SystemTray tray = SystemTray.getSystemTray();
Image image = Toolkit.getDefaultToolkit().getImage("C:\logo.png");
final PopupMenu popup = new PopupMenu();
MenuItem aboutItem = new MenuItem("WS");
Menu displayMenu = new Menu("Hora de Inicio");
MenuItem hora = new MenuItem(tempo);
popup.add(aboutItem);
popup.addSeparator();
popup.add(displayMenu);
displayMenu.add(hora);
TrayIcon trayIcon = new TrayIcon(image, "WebService", popup);
trayIcon.setImageAutoSize(true);
try {
tray.add(trayIcon);
this.setVisible(false);
trayIcon.displayMessage("Aviso!", "Programa continua em execução...", TrayIcon.MessageType.INFO);
} catch (AWTException e) {
System.err.println("Não pode adicionar a tray");
}
} else {
System.err.println("Tray indisponível");
}
}
};
EventQueue.invokeLater(runner);
How do I run this application:
After performing the build in NetBeans I simply use " java -jar ws.jar
" or I use Launch4j, I create a exe
and double click. It displays a black window (application default + windows
What I would like would be to hide the screen above and leave it only via tray (do not run the risk of someone closing the console and stopping the application)