SysTrayIcon sysTray = new SysTrayIcon(); // Instanziert die Methode f¸r den SystemTray unter Windows
String sysTrayIcon = "tray.ICO";
String sysTrayToolTip = " Grosse Schuluhr V1.2 ";
try
{
sysTray.setIcon(sysTrayIcon, sysTrayToolTip); // F¸gt dem SystemTray mit einem Ikon und Tooltip unter Windows hinzu
}
catch(SysTrayIconException exc) // F‰ngt Fehler ab
{
System.out.println(exc.getMessage());
}
if (minArg)
{
sysTray.addMenuItem("Zeigen",false); // F¸gt ein SystemTray Men¸ Eintrag hinzu
sysTray.addMenuItem("Verstecken",true);
}
else
{
sysTray.addMenuItem("Zeigen",true);
sysTray.addMenuItem("Verstecken",false);
}
sysTray.addMenuItem("Info",false,true);
sysTray.addMenuItem("Beenden");
sysTray.setPopupMenu(2);
sysTray.addPropertyChangeListener(new java.beans.PropertyChangeListener() { // Dieser Bereich definiert was man gemacht werden soll
public final void propertyChange(java.beans.PropertyChangeEvent e) {
// Left mouse button event listener
if(e.getPropertyName().equals("LM_Button")) {
if (isVisible())
{
setVisible(false);
sysTray.replaceItem(1,false);
sysTray.replaceItem(2,true);
}
else
{
setVisible(true);
sysTray.replaceItem(1,true);
sysTray.replaceItem(2,false);
}
}
// Right mouse button event listener
/* if(e.getPropertyName().equals("RM_Button")) {
// ...
}
*/ // "Zeigen" menu item event listener
if(e.getPropertyName().equals("Zeigen")) {
setVisible(true);
sysTray.replaceItem(1,true);
sysTray.replaceItem(2,false);
}
// "Verstecken" menu item event listener
if(e.getPropertyName().equals("Verstecken")) {
setVisible(false);
sysTray.replaceItem(1,false);
sysTray.replaceItem(2,true);
}
// "Info" menu item event listener
if(e.getPropertyName().equals("Info")) {
openInfoWindow();
}
// "Exit" menu item event listener
if(e.getPropertyName().equals("Beenden")) {
sysTray.freeMemoryExit();
setVisible(false);
dispose();
System.exit(0);
}
}
});