Exemplo n.º 1
0
  private void initializeTray() {
    tray =
        new JXTrayIcon(
            IconManager.getIcon("arrow_divide").getImage(),
            Launcher.getName() + " - " + Launcher.getVersion());
    popup = buildPopupMenu();

    tray.setJPopupMenu(popup);
    tray.addActionListener(this);
    tray.setActionCommand("tray");

    SystemTray systemTray = SystemTray.getSystemTray();
    try {
      log.debug("Adding to tray");
      systemTray.add(tray);
    } catch (AWTException e) {
      log.error(e);
    }
    if (Prefs.prefs.at("app.displaywelcome").asBoolean()) {
      Tray.publishMessage("Rightclick the icon for more information.", "Thanks for trying BeST!");
      Prefs.prefs.set("app.displaywelcome", false);
      Prefs.save();
    }
  }
Exemplo n.º 2
0
  private JPopupMenu buildPopupMenu() {
    JPopupMenu popup = new JPopupMenu();

    /* Help -->
     *      About
     *      Instructions
     * -----------------
     * Take Screenshot
     * Save Text
     * Preferences
     * ----
     * Exit
     */

    JMenu helpMenu = new JMenu("Help", true);
    JMenuItem helpAboutMenu = new JMenuItem("About", IconManager.getIcon("help"));
    JMenuItem helpInstructMenu = new JMenuItem("Instructions", IconManager.getIcon("information"));
    helpMenu.add(helpAboutMenu);
    helpMenu.add(helpInstructMenu);
    helpAboutMenu.addActionListener(this);
    helpInstructMenu.addActionListener(this);
    helpAboutMenu.setActionCommand("about");
    helpInstructMenu.setActionCommand("instructions");

    JMenuItem screenshotMenu = new JMenuItem("Take Screenshot", IconManager.getIcon("camera_link"));
    screenshotMenu.addActionListener(this);
    screenshotMenu.setActionCommand("screenshot");

    //        JMenuItem saveTextMenu = new JMenuItem("Save Text to Pastebin",
    // IconManager.getIcon("page_white_link"));
    //        saveTextMenu.addActionListener(this);
    //        saveTextMenu.setActionCommand("text");

    JMenuItem preferencesMenu = new JMenuItem("Preferences", IconManager.getIcon("cog"));
    preferencesMenu.addActionListener(this);
    preferencesMenu.setActionCommand("preferences");

    JMenuItem toolsMenu = new JMenuItem("Tools", IconManager.getIcon("wrench"));
    toolsMenu.addActionListener(this);
    toolsMenu.setActionCommand("tools");

    JMenuItem exitMenu = new JMenuItem("Exit", IconManager.getIcon("cancel"));
    exitMenu.addActionListener(this);
    exitMenu.setActionCommand("exit");

    JMenuItem debugMenu = new JMenuItem("Debug");
    debugMenu.addActionListener(this);
    debugMenu.setActionCommand("debug");

    popup.add(helpMenu);
    popup.addSeparator();
    popup.add(screenshotMenu);
    //        popup.add(saveTextMenu);
    popup.add(toolsMenu);
    popup.add(preferencesMenu);
    popup.addSeparator();
    popup.add(exitMenu);
    popup.addSeparator();
    popup.add(debugMenu);

    return popup;
  }