' inline java "doit()" called before starting server
...
Sub stoppit ' called from java code
StopMessageLoop
ExitApplication
End Sub
...
#if java
import java.awt.*;
import java.awt.event.*;
public static void doIt(){
TrayIcon trayIcon = null;
if (SystemTray.isSupported()) {
SystemTray tray = SystemTray.getSystemTray();
Image image = Toolkit.getDefaultToolkit().getImage("c:/temp/hannah.jpg");
if (image==null) System.out.println("image error");
ActionListener listener = new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.out.println("Closing the server");
try{
_stoppit();
} catch (Exception ure){
}
}
};
PopupMenu popup = new PopupMenu();
MenuItem defaultItem = new MenuItem("Shutdown Server");
defaultItem.addActionListener(listener);
popup.add(defaultItem);
trayIcon = new TrayIcon(image, "Server Control", popup);
trayIcon.addActionListener(listener);
try {
tray.add(trayIcon);
} catch (AWTException e) {
System.err.println(e);
}
} else {
System.out.println("Can't sccess systemtray");
}
}
#End If