Beispiel #1
0
  private MainPanel(final JFrame frame) {
    super();
    add(check);
    setPreferredSize(new Dimension(320, 240));

    if (!SystemTray.isSupported()) {
      frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
      return;
    }
    frame.addWindowListener(
        new WindowAdapter() {
          @Override
          public void windowIconified(WindowEvent e) {
            if (check.isSelected()) {
              e.getWindow().dispose();
            }
          }
        });
    // or
    // frame.addWindowStateListener(new WindowStateListener() {
    //    @Override public void windowStateChanged(WindowEvent e) {
    //        if (check.isSelected() && e.getNewState() == Frame.ICONIFIED) {
    //            e.getWindow().dispose();
    //        }
    //    }
    // });

    final SystemTray tray = SystemTray.getSystemTray();
    Dimension d = tray.getTrayIconSize();
    BufferedImage image = makeBufferedImage(new StarIcon(), d.width, d.height);
    final PopupMenu popup = new PopupMenu();
    final TrayIcon icon = new TrayIcon(image, "TRAY", popup);

    MenuItem item1 = new MenuItem("OPEN");
    item1.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            frame.setVisible(true);
          }
        });
    MenuItem item2 = new MenuItem("EXIT");
    item2.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            tray.remove(icon);
            frame.dispose();
            // frame.dispatchEvent(new WindowEvent(frame, WindowEvent.WINDOW_CLOSING));
          }
        });
    popup.add(item1);
    popup.add(item2);

    try {
      tray.add(icon);
    } catch (AWTException e) {
      e.printStackTrace();
    }
  }
Beispiel #2
0
  public void setFormatsMenu(FileFormat[] supportedFormats, jMESYS t) throws Exception {

    if (supportedFormats != null) {

      int lenFormats = supportedFormats.length;
      System.out.println("Leo Formatos...");
      for (int i = 0; i < lenFormats; i++) {
        jMESYSMenuItem mItem =
            new jMESYSMenuItem(supportedFormats[i].getExtension(), supportedFormats[i]);
        System.out.println(supportedFormats[i].getFileName());
        mItem.setFileName(supportedFormats[i].getFileName());
        mItem.addActionListener(t);
        mOpen.add(mItem);
      }

      mOpen.addSeparator();
      MenuItem allFormats = new MenuItem("All Formats");
      allFormats.addActionListener(t);
      mOpen.add(allFormats);

      mOpen.addSeparator();
      MenuItem mWOS = new MenuItem("Remote WOS");
      mWOS.addActionListener(t);
      mOpen.add(mWOS);

    } else {
      System.out.println("+++No supported files+++");
    }
  }
Beispiel #3
0
  protected PopupMenu getNetTunnelMenu(NetTunnel tunnel) {
    PopupMenu menu = new PopupMenu();
    PopupMenuListener pml = new NetTunnelPopupListener(tunnel, controller);

    String[] items = {
      "Track roadusers arrived",
      "Track trip waiting time",
      "Track waiting (receive) queue",
      "Track send queue"
    };
    MenuItem item;

    for (int i = 0; i < items.length; i++) {
      item = new MenuItem(items[i]);
      item.addActionListener(pml);
      menu.add(item);
    }

    menu.add(new MenuItem("-"));

    item = new MenuItem("Properties...", new MenuShortcut(KeyEvent.VK_ENTER));
    item.addActionListener(pml);
    menu.add(item);

    return menu;
  }
Beispiel #4
0
  private static void createAndShowGUI() {
    // Check the SystemTray support
    if (!SystemTray.isSupported()) {
      System.out.println("SystemTray is not supported");
      return;
    }
    final PopupMenu popup = new PopupMenu();
    final TrayIcon trayIcon = new TrayIcon(createImage("logo.gif", "tray icon"));
    final SystemTray tray = SystemTray.getSystemTray();

    // Create a popup menu components
    MenuItem aboutItem = new MenuItem("About");
    MenuItem exitItem = new MenuItem("Exit");

    // Add components to popup menu
    popup.add(aboutItem);
    popup.addSeparator();
    popup.add(exitItem);

    trayIcon.setPopupMenu(popup);
    trayIcon.setImageAutoSize(true);
    trayIcon.setToolTip("Geomar Wetterdaten");

    try {
      tray.add(trayIcon);
    } catch (AWTException e) {
      System.out.println("TrayIcon could not be added.");
      return;
    }

    trayIcon.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            JOptionPane.showMessageDialog(null, "This dialog box is run from System Tray");
          }
        });

    aboutItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            JOptionPane.showMessageDialog(
                null,
                "Windgeschwindigkeit: "
                    + weather.getWindspeed()
                    + "m/s\n"
                    + "Windrichtung: "
                    + weather.getDirection()
                    + "° "
                    + weather.calcDir(weather.getDirection()));
          }
        });

    exitItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            tray.remove(trayIcon);
            System.exit(0);
          }
        });
  }
Beispiel #5
0
 public CutAndPaste() {
   cut.addActionListener(new CutL());
   copy.addActionListener(new CopyL());
   paste.addActionListener(new PasteL());
   edit.add(cut);
   edit.add(copy);
   edit.add(paste);
   mb.add(edit);
   setMenuBar(mb);
   add(text, BorderLayout.CENTER);
 }
Beispiel #6
0
    /** 给组件添加监听事件 */
    void setEvent() {
      System.out.println("设置菜单监听");

      // 按键添加监听
      bt0_HomePanel.addActionListener(new MyBtMenuListener());
      bt1_SettingPanel.addActionListener(new MyBtMenuListener());
      bt2_DrawwingPanel.addActionListener(new MyBtMenuListener());
      bt3_InternetPanel.addActionListener(new MyBtMenuListener());
      bt4_OtherPanel.addActionListener(new MyBtMenuListener());

      // 菜单项监听
      mi_0.addActionListener(new MyMenuItemsListener());
      mi_1.addActionListener(new MyMenuItemsListener());
      mi_2.addActionListener(new MyMenuItemsListener());
    }
  private void initFontMenu() {
    Menu fontMenu = new Menu("font");
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    Font[] fontSet = ge.getAllFonts();
    List<String> list = new ArrayList<>();
    for (Font f : fontSet) {
      list.add(f.getName());
    }
    int num = DigitalClockWindow.EXCLUDED_FONTS.length;
    for (int i = 0; i < num; i++) {
      list.remove(DigitalClockWindow.EXCLUDED_FONTS[i]);
    }
    for (final String fontName : list) {
      MenuItem mi = new MenuItem(fontName);
      mi.addActionListener(
          new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
              DigitalClockProperty.PROPERTY.setFontName(fontName);
              digitalClockPropertyObserver.notifyPropertyChanged(DigitalClockProperty.PROPERTY);
              DigitalClockPopupMenu.this.setFont(POPUP_MENU_FONT);
            }
          });
      fontMenu.add(mi);
    }
    add(fontMenu);
  }
Beispiel #8
0
private void MenuPopup (MouseEvent ev, CGNode node)
    {
	if (!node.IsConcept())
	    return;

	String menuname = (String)menumap.get (node.GetType(true));
	if (menuname == null)
	    return;
	Hashtable templates = (Hashtable)menus.get (menuname);
	if (templates == null)
	    return;

	if( popup != null )
	  remove( popup );

	popup = new PopupMenu( menuname );
	
        Enumeration e = templates.keys();
        while (e.hasMoreElements()) {
            String key = (String)e.nextElement();
	    MenuItem mi = new MenuItem( key );
	    mi.setActionCommand( key );
	    mi.addActionListener( this );
	    popup.add( mi );
        }
        curnode = node;

	this.add( popup );

	popup.show( this, ev.getX(), ev.getY() );
    }
  private void initFontColorMenu() {
    Menu fontColorMenu = new Menu("font color");
    for (final Entry<String, Color> colorEntry : colorSet.entrySet()) {
      MenuItem mi = new MenuItem(colorEntry.getKey());
      mi.addActionListener(
          new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
              if (colorEntry
                  .getValue()
                  .equals(DigitalClockProperty.PROPERTY.getBackgroungColor())) {
                ErrorMessageDialog.showErrorMessage(
                    colorEntry.getKey()
                        + " is same color of background. Select different color for font.");
                return;
              }
              DigitalClockProperty.PROPERTY.setFontColor(colorEntry.getValue());
              digitalClockPropertyObserver.notifyPropertyChanged(DigitalClockProperty.PROPERTY);
              DigitalClockPopupMenu.this.setFont(POPUP_MENU_FONT);
            }
          });
      fontColorMenu.add(mi);
    }
    add(fontColorMenu);
  }
  public SplashDemo() throws NullPointerException, IllegalStateException, IOException {
    super("SplashScreen demo");
    setSize(300, 200);
    setLayout(new BorderLayout());
    Menu m1 = new Menu("File");
    MenuItem mi1 = new MenuItem("Exit");
    m1.add(mi1);
    mi1.addActionListener(this);
    this.addWindowListener(closeWindow);

    MenuBar mb = new MenuBar();
    setMenuBar(mb);
    mb.add(m1);
    final SplashScreen splash = SplashScreen.getSplashScreen();
    if (splash == null) {
      System.out.println("SplashScreen.getSplashScreen() returned null");
      return;
    }
    Graphics2D g = splash.createGraphics();
    if (g == null) {
      System.out.println("g is null");
      return;
    }
    for (int i = 0; i < 100; i++) {
      renderSplashFrame(g, i);
      splash.update();
      try {
        Thread.sleep(90);
      } catch (InterruptedException e) {
      }
    }
    splash.close();
    setVisible(true);
    toFront();
  }
 protected final MenuItem createMenuItem(String _key, String _header, ActionListener _al) {
   MenuItem mi = new MenuItem(res.getString("TabbedEditor." + _key));
   mi.setActionCommand(_key);
   mi.addActionListener(_al);
   popupMenu.add(mi);
   return mi;
 }
Beispiel #12
0
  Timed() throws AWTException {
    // super("Trial by fire");
    setLayout(new FlowLayout());

    label.setFont(
        new Font(
            label.getFont().getName(), label.getFont().getStyle(), label.getFont().getSize() + 6));
    Container content = getContentPane();
    content.add(label, JLabel.CENTER);
    addMouseMotionListener(this);
    addMouseListener(this);

    javax.swing.Timer t = new javax.swing.Timer(1000, this);
    setUndecorated(true);
    com.sun.awt.AWTUtilities.setWindowOpacity(this, 0.6f);

    // system tray
    mItem1.addActionListener(
        new ActionListener() {

          public void actionPerformed(ActionEvent e) {
            System.exit(0);
          }
        });

    popup.add(mItem1);
    systray.add(tray);
    tray.setImageAutoSize(true);
    t.start();
  }
  /**
   * Method declaration
   *
   * @param s
   */
  private void addToRecent(String s) {

    for (int i = 0; i < iMaxRecent; i++) {
      if (s.equals(sRecent[i])) {
        return;
      }
    }

    if (sRecent[iRecent] != null) {
      mRecent.remove(iRecent);
    }

    sRecent[iRecent] = s;

    if (s.length() > 43) {
      s = s.substring(0, 40) + "...";
    }

    MenuItem item = new MenuItem(s);

    item.setActionCommand("#" + iRecent);
    item.addActionListener(this);
    mRecent.insert(item, iRecent);

    iRecent = (iRecent + 1) % iMaxRecent;
  }
  DigitalClockPopupMenu(DigitalClockPropertyObserver digitalClockPropertyObserver) {
    this.digitalClockPropertyObserver = digitalClockPropertyObserver;
    setFont(POPUP_MENU_FONT);

    colorSet.put("BLACK", Color.BLACK);
    colorSet.put("BLUE", Color.BLUE);
    colorSet.put("CYAN", Color.CYAN);
    colorSet.put("DARK GRAY", Color.DARK_GRAY);
    colorSet.put("GRAY", Color.GRAY);
    colorSet.put("GREEN", Color.GREEN);
    colorSet.put("LIGTHT GRAY", Color.LIGHT_GRAY);
    colorSet.put("MAGENTA", Color.MAGENTA);
    colorSet.put("ORANGE", Color.ORANGE);
    colorSet.put("PINK", Color.PINK);
    colorSet.put("RED", Color.RED);
    colorSet.put("WHITE", Color.WHITE);
    colorSet.put("YELLOW", Color.YELLOW);

    initFontMenu();
    initFontSizeMenu();
    initFontColorMenu();
    initBackgroungColorMenu();

    addSeparator();
    MenuItem exitMenu = new MenuItem("exit");
    exitMenu.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            System.exit(0);
          }
        });
    add(exitMenu);
  }
Beispiel #15
0
  public MagicRobot(
      double first,
      double second,
      EasyFrame frameIn) // this is constructor as it has the same name as the class
      {

    frameIn.setMenuBar(menu);
    menu.add(functions);
    menu.add(colors);

    parentFrame = frameIn;
    add(colorButton);
    colorButton.addActionListener(this);

    number1 = first;
    number2 = second;
    // add visual components
    functions.add(addButton);
    functions.add(subtractButton);
    functions.add(multButton);
    functions.add(divideButton);
    functions.add(remButton);
    colors.add(blueButton);
    colors.add(greenButton);
    subtractButton.addActionListener(this);
    addButton.addActionListener(this);
    multButton.addActionListener(this);
    divideButton.addActionListener(this);
    remButton.addActionListener(this);
    blueButton.addActionListener(this);
    greenButton.addActionListener(this);
  }
Beispiel #16
0
  public void event() {

    // 종료 메뉴에 event 설정
    fexit.addActionListener(this); // bt.addActionListener(처리대상); 나 : this , 남 : 객체

    for (int i = 0; i < bt.length; i++) {
      bt[i].addActionListener(this);
    }
  }
 public void setTray() {
   if (SystemTray.isSupported()) {
     Image icon =
         Toolkit.getDefaultToolkit().getImage("C:/.hack3rClient/sprites/cursors/icon.png");
     trayIcon = new TrayIcon(icon, "Vestige-x");
     trayIcon.setImageAutoSize(true);
     try {
       SystemTray tray = SystemTray.getSystemTray();
       tray.add(trayIcon);
       trayIcon.displayMessage(
           "Vestige-x", "Vestige-x has been launched!", TrayIcon.MessageType.INFO);
       PopupMenu menu = new PopupMenu();
       final MenuItem minimizeItem = new MenuItem("Hide Vestige-x");
       MenuItem BLANK = new MenuItem("-");
       MenuItem exitItem = new MenuItem("Quit");
       menu.add(minimizeItem);
       menu.add(BLANK);
       menu.add(exitItem);
       trayIcon.setPopupMenu(menu);
       ActionListener minimizeListener =
           new ActionListener() {
             public void actionPerformed(ActionEvent e) {
               if (frame.isVisible()) {
                 frame.setVisible(false);
                 minimizeItem.setLabel("Show 1# Vestige-x.");
               } else {
                 frame.setVisible(true);
                 minimizeItem.setLabel("Hide 1# Vestige-x.");
               }
             }
           };
       minimizeItem.addActionListener(minimizeListener);
       ActionListener exitListener =
           new ActionListener() {
             public void actionPerformed(ActionEvent e) {
               System.exit(0);
             }
           };
       exitItem.addActionListener(exitListener);
     } catch (AWTException e) {
       System.err.println(e);
     }
   }
 }
  public MenuFrame(String title) {
    super(title);
    this.m_file = new Menu("File");
    this.m_edit = new Menu("Edit");
    this.cm_debug = new CheckboxMenuItem("Debug");
    this.cm_test = new CheckboxMenuItem("Test");
    this.p_debug = new Panel();

    MenuFrameListener listener = new MenuFrameListener();

    Menu m_sub = new Menu("Additional");
    MenuItem mi_new = new MenuItem("New...");
    MenuItem mi_open = new MenuItem("Open...");
    MenuItem mi_close = new MenuItem("Close...");
    MenuItem mi_cut = new MenuItem("Cut");
    MenuItem mi_copy = new MenuItem("Copy");
    MenuItem mi_paste = new MenuItem("Paste");
    MenuItem mi_one = new MenuItem("One!");
    MenuItem mi_two = new MenuItem("Two!");
    MenuItem mi_three = new MenuItem("Three!");

    mi_new.addActionListener(listener);
    mi_open.addActionListener(listener);
    mi_close.addActionListener(listener);
    mi_cut.addActionListener(listener);
    mi_copy.addActionListener(listener);
    mi_paste.addActionListener(listener);
    mi_one.addActionListener(listener);
    mi_two.addActionListener(listener);
    mi_three.addActionListener(listener);
    cm_debug.addItemListener(listener);
    cm_test.addItemListener(listener);

    m_sub.add(mi_one);
    m_sub.add(mi_two);
    m_sub.add(mi_three);
    m_file.add(mi_open);
    m_file.add(mi_new);
    m_file.add(mi_close);
    m_edit.add(mi_cut);
    m_edit.add(mi_copy);
    m_edit.add(mi_paste);
    m_edit.add(m_sub);
    m_edit.add(cm_test);
    m_edit.add(cm_debug);

    initWindow();
  }
Beispiel #19
0
  protected PopupMenu getDrivelaneMenu(Drivelane l) {
    PopupMenu menu = new PopupMenu();
    PopupMenuListener pml = new LanePopupListener(l, controller);

    MenuItem item = new MenuItem("Properties...", new MenuShortcut(KeyEvent.VK_ENTER));
    item.addActionListener(pml);
    menu.add(item);

    return menu;
  }
Beispiel #20
0
  protected PopupMenu getRoadMenu(Road r) {
    PopupMenu menu = new PopupMenu();
    PopupMenuListener pml = new RoadPopupListener(r, controller);

    MenuItem item = new MenuItem("Properties...", new MenuShortcut(KeyEvent.VK_ENTER));
    item.addActionListener(pml);
    menu.add(item);

    return menu;
  }
  public void init() {
    final TrayIcon trayIcon;

    if (!SystemTray.isSupported()) {
      System.err.println("SystemTray is not supported");
      return;
    }

    SystemTray tray = SystemTray.getSystemTray();

    Image image =
        new ImageIcon(getClass().getResource("/threaded/ThreadedEshoServer/db_settings_32.png"))
            .getImage();

    // ‘ормирование меню
    PopupMenu popup = new PopupMenu();
    MenuItem exitItem = new MenuItem("Exit");
    exitItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            System.exit(0);
          }
        });
    popup.add(exitItem);

    trayIcon = new TrayIcon(image, "My server", popup);
    trayIcon.setImageAutoSize(true);
    trayIcon.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            trayIcon.displayMessage(
                "My server", "—ообщение по дабл клику", TrayIcon.MessageType.INFO);
          }
        });

    try {
      tray.add(trayIcon);
    } catch (AWTException e) {
      System.err.println("TrayIcon could not be added");
      return;
    }

    Timer timer =
        new Timer(
            10000,
            new ActionListener() {

              @Override
              public void actionPerformed(ActionEvent e) {
                // trayIcon.displayMessage("Your messages:",
                // "я вывел это сообщение", TrayIcon.MessageType.INFO);
              }
            });
    timer.start();
  }
Beispiel #22
0
  public Tray() {

    if (SystemTray.isSupported()) {

      EventHandler EH = new EventHandler();

      SystemTray Tray = SystemTray.getSystemTray();
      Toolkit tk = Toolkit.getDefaultToolkit();
      Image img =
          tk.getImage(
              System.getProperty("user.dir")
                  + fileSeparator
                  + "res"
                  + fileSeparator
                  + "notica.png");

      PopupMenu menu = new PopupMenu();
      MenuItem action = new MenuItem("Nueva Nota");
      MenuItem Close = new MenuItem("Cerrar");

      action.addActionListener(EH.addNote());
      Close.addActionListener(EH.Cerrar());

      menu.add(action);
      menu.add(Close);

      TrayIcon ti = new TrayIcon(img, "Knote 1.0", menu);
      ti.setImageAutoSize(true);

      try {
        Tray.add(ti);

      } catch (AWTException ex) {
        ex.printStackTrace();
        System.out.println("Error AWTException " + ex.getMessage());
      }

    } else {
      System.out.println("System Tray is not supported");
      return;
    }
  }
Beispiel #23
0
  protected PopupMenu getJunctionMenu(Junction junction) {
    PopupMenu menu = new PopupMenu();
    PopupMenuListener pml = new JunctionPopupListener(junction, controller);

    String[] items = {"Track roadusers that crossed", "Track junction waiting time"};
    MenuItem item;

    for (int i = 0; i < items.length; i++) {
      item = new MenuItem(items[i]);
      item.addActionListener(pml);
      menu.add(item);
    }

    menu.add(new MenuItem("-"));

    item = new MenuItem("Properties...", new MenuShortcut(KeyEvent.VK_ENTER));
    item.addActionListener(pml);
    menu.add(item);

    return menu;
  }
Beispiel #24
0
  private Menu createFileMenu() {
    Menu fileMenu = new Menu("File");
    fileMenu.add(quitItem = new MenuItem("Quit"));

    quitItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            dispose();
            System.exit(0);
          }
        });
    return fileMenu;
  }
Beispiel #25
0
  protected PopupMenu getEdgeNodeMenu(EdgeNode edge) {
    PopupMenu menu = new PopupMenu();
    PopupMenuListener pml = new EdgeNodePopupListener(edge, controller);

    String[] items = {
      "Track waiting queue length", "Track roadusers arrived", "Track trip waiting time"
    };
    MenuItem item;

    for (int i = 0; i < items.length; i++) {
      item = new MenuItem(items[i]);
      item.addActionListener(pml);
      menu.add(item);
    }

    menu.add(new MenuItem("-"));

    item = new MenuItem("Properties...", new MenuShortcut(KeyEvent.VK_ENTER));
    item.addActionListener(pml);
    menu.add(item);

    return menu;
  }
Beispiel #26
0
  /**
   * Reads the <code>ObjectInputStream</code> and if it isn't <code>null</code> adds a listener to
   * receive action events fired by the <code>Menu</code> Item. Unrecognized keys or values will be
   * ignored.
   *
   * @param s the <code>ObjectInputStream</code> to read
   * @exception HeadlessException if <code>GraphicsEnvironment.isHeadless</code> returns <code>true
   *     </code>
   * @see #removeActionListener(ActionListener)
   * @see #addActionListener(ActionListener)
   * @see #writeObject(ObjectOutputStream)
   */
  private void readObject(ObjectInputStream s)
      throws ClassNotFoundException, IOException, HeadlessException {
    // HeadlessException will be thrown from MenuComponent's readObject
    s.defaultReadObject();

    Object keyOrNull;
    while (null != (keyOrNull = s.readObject())) {
      String key = ((String) keyOrNull).intern();

      if (actionListenerK == key) addActionListener((ActionListener) (s.readObject()));
      else // skip value for unrecognized key
      s.readObject();
    }
  }
  /**
   * Method declaration
   *
   * @param f
   * @param m
   */
  void addMenuItems(Menu f, String m[]) {

    for (int i = 0; i < m.length; i++) {
      MenuItem item = new MenuItem(m[i].substring(1));
      char c = m[i].charAt(0);

      if (c != '-') {
        item.setShortcut(new MenuShortcut(c));
      }

      item.addActionListener(this);
      f.add(item);
    }
  }
  void setUpWindowsNotifications() throws AWTException {
    Image image = null;

    URL url = getClass().getResource("/SyncropIcon.png");
    // url=getClass().getClassLoader().getResource("SyncropIcon.png");
    // url=ClassLoader.getSystemResource("SyncropIcon.png");

    image =
        new ImageIcon(url, "Syncrop icon").getImage().getScaledInstance(16, 16, Image.SCALE_SMOOTH);
    logger.log(image + "");
    trayIcon = new TrayIcon(image, "Syncrop");
    help.addActionListener(this);
    about.addActionListener(this);
    update.addActionListener(this);
    exit.addActionListener(this);

    popup.add(help);
    popup.add(about);
    popup.add(update);
    popup.add(exit);

    trayIcon.setPopupMenu(popup);
    notificationsTray.add(trayIcon);
  }
 void installPopupMenu(String name, Program pgm) {
   Hashtable h = pgm.getMenus();
   if (h == null) return;
   String[] commands = (String[]) h.get(name);
   if (commands == null) return;
   PopupMenu popup = Menus.getPopupMenu();
   if (popup == null) return;
   popup.removeAll();
   for (int i = 0; i < commands.length; i++) {
     if (commands[i].equals("-")) popup.addSeparator();
     else {
       MenuItem mi = new MenuItem(commands[i]);
       mi.addActionListener(this);
       popup.add(mi);
     }
   }
 }
Beispiel #30
0
  /* TODO: sorted */
  public static MenuItem installPlugin(String menuPath, String name, String command) {
    if (Menus.getCommands().get(name) != null) {
      IJ.log("The user plugin " + name + " would override an existing command!");
      return null;
    }

    MenuItem item = null;
    if (IJ.getInstance() != null) {
      int croc = menuPath.lastIndexOf('>');
      Menu menu = getMenu(menuPath);
      item = new MenuItem(name);
      menu.add(item);
      item.addActionListener(IJ.getInstance());
    }
    Menus.getCommands().put(name, command);
    return item;
  }