Skip to content
dorkbox edited this page Nov 4, 2014 · 2 revisions

Example

SystemTray tray = SystemTray.create("Dorkbox");

tray.createTray("gray_icon.png");

tray.setStatus("Disconnected...", "gray_icon.png");


tray.addMenuEntry("Show App", new SystemTrayMenuAction() {
    @Override
    public void onClick(SystemTray systemTray) {
        logger.debug("1 called");

        systemTray.updateMenuEntry("Show App", "TERMINATE!", new SystemTrayMenuAction() {
            @Override
            public void onClick(SystemTray systemTray) {
                logger.debug("2 called");
                systemTray.removeTray();
                System.exit(0);
            }});
        systemTray.setStatus("Connected", "green_icon.png");
    }
});


tray.addMenuEntry("Quit 1", new SystemTrayMenuAction() {
    @Override
    public void onClick(SystemTray systemTray) {
        logger.debug("quit 1 called");
        systemTray.removeTray();
        System.exit(0);
    }
});

tray.addMenuEntry("Quit 2", new SystemTrayMenuAction() {
    @Override
    public void onClick(SystemTray systemTray) {
        logger.debug("quit 2 called");
        systemTray.removeTray();
        System.exit(0);
    }
});


try {
    Thread.sleep(50000000);
} catch (Exception e) {
    e.printStackTrace();
}
Clone this wiki locally