Package java.awt

Examples of java.awt.PopupMenu$AccessibleAWTPopupMenu



            SystemTray tray = SystemTray.getSystemTray();

            // create menu
            PopupMenu popup = new PopupMenu();


            //MenuItem mainPage = createMenuItem("Start Page", "http://"+getServerName()+":"+getServerPort()+"/");
            //popup.add(mainPage);

            popup.addSeparator();


            // launch browser action
            MenuItem admin = createMenuItem("Administration","http://"+getServerName()+":"+getServerPort()+"/");
            popup.add(admin);

            // admin links

            for(final Map.Entry<String,String> linkEntry : adminLinks.entrySet()) {
                MenuItem entry = createMenuItem(linkEntry.getKey(),linkEntry.getValue());
                popup.add(entry);
            }

            // shutdown action
            MenuItem shutdown = new MenuItem("Shutdown");
            try {
                Class.forName("org.apache.catalina.mbeans.MBeanUtils");
                ActionListener stopListener = new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent e) {
                        performServerShutdown();
                    }
                };
                shutdown.addActionListener(stopListener);
            } catch (ClassNotFoundException e) {
                shutdown.setEnabled(false);
            }
            popup.add(shutdown);

            popup.addSeparator();

            for(final Map.Entry<String,String> linkEntry : demoLinks.entrySet()) {
                boolean containsEntry = false;
                for(int i = 0; i < popup.getItemCount(); i++) {
                    MenuItem item = popup.getItem(i);
                    if(item.getLabel().equals(linkEntry.getKey())) {
                        containsEntry = true;
                        break;
                    }
                }

                if(!containsEntry) {
                    MenuItem entry = createMenuItem(linkEntry.getKey(),linkEntry.getValue());
                    popup.add(entry);
                }
            }

            popup.addSeparator();

            MenuItem about = new MenuItem("About");
            about.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    TaskDialogs.inform(null,
                            "About Apache Marmotta \n",
                            "(c)2013 The Apache Software Foundation \n" +
                            "Visit http://marmotta.incubator.apache.org for further details");
                }
            });
            popup.add(about);

            MenuItem issues = createMenuItem("Issues Reports", "https://issues.apache.org/jira/browse/MARMOTTA");
            popup.add(issues);

            MenuItem homepage = createMenuItem("Project Homepage", "http://marmotta.incubator.apache.org");
            popup.add(homepage);


            // load icon image
            try {
                Image image = ImageIO.read(SystrayListener.class.getResource("systray.png"));
View Full Code Here



            SystemTray tray = SystemTray.getSystemTray();

            // create menu
            PopupMenu popup = new PopupMenu();


            //MenuItem mainPage = createMenuItem("Start Page", "http://"+getServerName()+":"+getServerPort()+"/");
            //popup.add(mainPage);
            //popup.addSeparator();


            // launch browser action
            MenuItem admin = createMenuItem("Administration","http://"+getServerName()+":"+getServerPort()+"/");
            popup.add(admin);

            // admin links

            for(final Map.Entry<String,String> linkEntry : adminLinks.entrySet()) {
                MenuItem entry = createMenuItem(linkEntry.getKey(),linkEntry.getValue());
                popup.add(entry);
            }

            // shutdown action
            MenuItem shutdown = new MenuItem("Shutdown");
            try {
                Class.forName("org.apache.catalina.mbeans.MBeanUtils");
                ActionListener stopListener = new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent e) {
                        performServerShutdown();
                    }
                };
                shutdown.addActionListener(stopListener);
            } catch (ClassNotFoundException e) {
                shutdown.setEnabled(false);
            }
            popup.add(shutdown);

           
            if (!demoLinks.isEmpty()) {
                popup.addSeparator();
            }
            for(final Map.Entry<String,String> linkEntry : demoLinks.entrySet()) {
                boolean containsEntry = false;
                for(int i = 0; i < popup.getItemCount(); i++) {
                    MenuItem item = popup.getItem(i);
                    if(item.getLabel().equals(linkEntry.getKey())) {
                        containsEntry = true;
                        break;
                    }
                }

                if(!containsEntry) {
                    MenuItem entry = createMenuItem(linkEntry.getKey(),linkEntry.getValue());
                    popup.add(entry);
                }
            }

            popup.addSeparator();
            MenuItem about = new MenuItem("About");
            about.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    MessageDialog.show("Apache Marmotta",
                            "About Apache Marmotta \n",
                            "(c)2014 The Apache Software Foundation \n" +
                            "Visit http://marmotta.apache.org for further details");
                }
            });
            popup.add(about);

            MenuItem issues = createMenuItem("Issues Reports", "https://issues.apache.org/jira/browse/MARMOTTA");
            popup.add(issues);

            MenuItem homepage = createMenuItem("Project Homepage", "http://marmotta.apache.org");
            popup.add(homepage);


            // load icon image
            try {
                Image image = ImageIO.read(SystrayListener.class.getResource("systray.png"));
View Full Code Here

            public void windowActivated(WindowEvent e)   { trayMenuMain.setLabel("Hide"); }
            public void windowDeactivated(WindowEvent e) { trayMenuMain.setLabel("Show"); }
            public void windowDeiconified(WindowEvent e) { trayMenuMain.setLabel("Hide"); }
            public void windowIconified(WindowEvent e)   { trayMenuMain.setLabel("Show"); }
        });
        PopupMenu trayMenu = new PopupMenu();
        trayMenuMain = new MenuItem("Hide");
        trayMenuMain.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent arg0) {
                toggleTrayClick();
            }
        });
        trayMenuAbout = new MenuItem("About " + mainFrame.getTitle());
        trayMenuAbout.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent arg0) {
                StringBuilder about = new StringBuilder();
                about.append("<html><h1>")
                     .append(mainFrame.getTitle())
                     .append("</h1>");
                about.append("Download albums from various websites:");
                try {
                    List<String> rippers = Utils.getListOfAlbumRippers();
                    about.append("<ul>");
                    for (String ripper : rippers) {
                        about.append("<li>");
                        ripper = ripper.substring(ripper.lastIndexOf('.') + 1);
                        if (ripper.contains("Ripper")) {
                            ripper = ripper.substring(0, ripper.indexOf("Ripper"));
                        }
                        about.append(ripper);
                        about.append("</li>");
                    }
                    about.append("</ul>");
                } catch (Exception e) { }
               about.append("<br>And download videos from video sites:");
                try {
                    List<String> rippers = Utils.getListOfVideoRippers();
                    about.append("<ul>");
                    for (String ripper : rippers) {
                        about.append("<li>");
                        ripper = ripper.substring(ripper.lastIndexOf('.') + 1);
                        if (ripper.contains("Ripper")) {
                            ripper = ripper.substring(0, ripper.indexOf("Ripper"));
                        }
                        about.append(ripper);
                        about.append("</li>");
                    }
                    about.append("</ul>");
                } catch (Exception e) { }

                about.append("Do you want to visit the project homepage on Github?");
                about.append("</html>");
                int response = JOptionPane.showConfirmDialog(null,
                        about.toString(),
                        mainFrame.getTitle(),
                        JOptionPane.YES_NO_OPTION,
                        JOptionPane.PLAIN_MESSAGE,
                        new ImageIcon(mainIcon));
                if (response == JOptionPane.YES_OPTION) {
                    try {
                        Desktop.getDesktop().browse(URI.create("http://github.com/4pr0n/ripme"));
                    } catch (IOException e) {
                        logger.error("Exception while opening project home page", e);
                    }
                }
            }
        });
        trayMenuExit = new MenuItem("Exit");
        trayMenuExit.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent arg0) {
                System.exit(0);
            }
        });
        trayMenuAutorip = new CheckboxMenuItem("Clipboard Autorip");
        trayMenuAutorip.addItemListener(new ItemListener() {
            @Override
            public void itemStateChanged(ItemEvent arg0) {
                ClipboardUtils.setClipboardAutoRip(trayMenuAutorip.getState());
                configClipboardAutorip.setSelected(trayMenuAutorip.getState());
            }
        });
        trayMenu.add(trayMenuMain);
        trayMenu.add(trayMenuAbout);
        trayMenu.addSeparator();
        trayMenu.add(trayMenuAutorip);
        trayMenu.addSeparator();
        trayMenu.add(trayMenuExit);
        try {
            mainIcon = ImageIO.read(getClass().getClassLoader().getResource("icon.png"));
            trayIcon = new TrayIcon(mainIcon);
            trayIcon.setToolTip(mainFrame.getTitle());
            trayIcon.setImageAutoSize(true);
View Full Code Here

        SystemTray tray = SystemTray.getSystemTray();
        if (!SystemTray.isSupported()) {
            throw new RuntimeException("Tray Not Supported");
        }
        trayIcon = new TrayIcon(normal, "Couch Audio Recorder");
        final PopupMenu popup = createMenu();

        trayIcon.setPopupMenu(popup);
        try {
            tray.add(trayIcon);
            //registerEvents();
View Full Code Here

    }



    private PopupMenu createMenu() {
        final PopupMenu popup = new PopupMenu("Couch Audio Recorder");
        {
            MenuItem item = new MenuItem("Exit");
            item.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    EventBus.publish(new ExitApplicationMessage());
                    try {
                        Thread.sleep(1000);
                        System.exit(0);
                    } catch (Exception ex) {
                    }
                   
                }
            });
            popup.add(item);

        }
        return popup;
    }
View Full Code Here

    final int xx = x;
    final int yy = y;
    int menuItemCount = 0;

    // modifications by Zerbetto
    PopupMenu beanContextMenu = new PopupMenu();

    //JPopupMenu beanContextMenu = new JPopupMenu();

    //    beanContextMenu.insert(new JLabel("Edit",
    //              SwingConstants.CENTER),
    //         menuItemCount);
    MenuItem edit = new MenuItem("Edit:");
    edit.setEnabled(false);
    beanContextMenu.insert(edit, menuItemCount);
    menuItemCount++;

    if (bc instanceof MetaBean) {
      //JMenuItem ungroupItem = new JMenuItem("Ungroup");
      MenuItem ungroupItem = new MenuItem("Ungroup");
      ungroupItem.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            // ungroup
            bi.removeBean(m_beanLayout);

            Vector group = ((MetaBean) bc).getBeansInSubFlow();
            Vector associatedConnections = ((MetaBean) bc).getAssociatedConnections();
            ((MetaBean) bc).restoreBeans();

            for (int i = 0; i < group.size(); i++) {
              BeanInstance tbi = (BeanInstance) group.elementAt(i);
              addComponent(tbi, false);
              tbi.addBean(m_beanLayout);
            }

            for (int i = 0; i < associatedConnections.size(); i++) {
              BeanConnection tbc = (BeanConnection) associatedConnections.elementAt(i);
              tbc.setHidden(false);
            }

            m_beanLayout.repaint();
            notifyIsDirty();
          }
        });
      beanContextMenu.add(ungroupItem);
      menuItemCount++;

      // Add to user tab
      //JMenuItem addToUserTabItem = new JMenuItem("Add to user tab");
      MenuItem addToUserTabItem = new MenuItem("Add to user tab");
      addToUserTabItem.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            addToUserToolBar((MetaBean) bi.getBean(), true);
            notifyIsDirty();
          }
        });
      beanContextMenu.add(addToUserTabItem);
      menuItemCount++;
    }

    //JMenuItem deleteItem = new JMenuItem("Delete");
    MenuItem deleteItem = new MenuItem("Delete");
    deleteItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
          BeanConnection.removeConnections(bi);
          bi.removeBean(m_beanLayout);
          revalidate();
          notifyIsDirty();
        }
      });
    beanContextMenu.add(deleteItem);
    menuItemCount++;

    if (bc instanceof BeanCommon) {
      MenuItem nameItem = new MenuItem("Set name");
      nameItem.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            String oldName = ((BeanCommon)bc).getCustomName();
            String name = JOptionPane.showInputDialog(KnowledgeFlowApp.this,
                                                      "Enter a name for this component",
                                                      oldName);
            if (name != null) {
              ((BeanCommon)bc).setCustomName(name);
            }
          }
        });
      beanContextMenu.add(nameItem);
      menuItemCount++;
    }

    try {
      //BeanInfo [] compInfo = null;
      //JComponent [] associatedBeans = null;
      Vector compInfo = new Vector(1);
      Vector associatedBeans = null;
      Vector outputBeans = null;
      Vector compInfoOutputs = null;

      if (bc instanceof MetaBean) {
        compInfo = ((MetaBean) bc).getBeanInfoSubFlow();
        associatedBeans = ((MetaBean) bc).getBeansInSubFlow();

        outputBeans = ((MetaBean) bc).getBeansInOutputs();
        compInfoOutputs = ((MetaBean) bc).getBeanInfoOutputs();
      } else {
        compInfo.add(Introspector.getBeanInfo(bc.getClass()));
        compInfoOutputs = compInfo;
      }

      final Vector tempAssociatedBeans = associatedBeans;

      if (compInfo == null) {
        System.err.println("[KnowledgeFlow] Error in doPopup()");
      } else {
        //  System.err.println("Got bean info");
        for (int zz = 0; zz < compInfo.size(); zz++) {
          final int tt = zz;
          final Class custClass = ((BeanInfo) compInfo.elementAt(zz)).getBeanDescriptor()
            .getCustomizerClass();

          if (custClass != null) {
            //    System.err.println("Got customizer class");
            //    popupCustomizer(custClass, bc);
            //JMenuItem custItem = null;
            MenuItem custItem = null;

            if (!(bc instanceof MetaBean)) {
              //custItem = new JMenuItem("Configure...");
              custItem = new MenuItem("Configure...");
            } else {
              String custName = custClass.getName();
              BeanInstance tbi = (BeanInstance) associatedBeans.elementAt(zz);

              if (tbi.getBean() instanceof WekaWrapper) {
                custName = ((WekaWrapper) tbi.getBean()).getWrappedAlgorithm()
                  .getClass().getName();
              } else {
                custName = custName.substring(0, custName.indexOf("Customizer"));
              }

              custName = custName.substring(custName.lastIndexOf('.') + 1,
                                            custName.length());
              //custItem = new JMenuItem("Configure: "+ custName);
              custItem = new MenuItem("Configure: " + custName);
            }

            custItem.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                  if (bc instanceof MetaBean) {
                    popupCustomizer(custClass,
                      (JComponent) ((BeanInstance) tempAssociatedBeans.
                                    elementAt(tt)).getBean());
                  } else {
                    popupCustomizer(custClass, bc);
                  }

                  notifyIsDirty();
                }
              });
            beanContextMenu.add(custItem);
            menuItemCount++;
          } else {
            System.err.println("[KnowledgeFlow] No customizer class");
          }
        }

        Vector esdV = new Vector();

        for (int i = 0; i < compInfoOutputs.size(); i++) {
          EventSetDescriptor[] temp =
            ((BeanInfo) compInfoOutputs.elementAt(i)).getEventSetDescriptors();

          if ((temp != null) && (temp.length > 0)) {
            esdV.add(temp);
          }
        }

        //        EventSetDescriptor [] esds = compInfo.getEventSetDescriptors();
        //        if (esds != null && esds.length > 0) {
        if (esdV.size() > 0) {
          //          beanContextMenu.insert(new JLabel("Connections",
          //                                            SwingConstants.CENTER),
          //                                 menuItemCount);
          MenuItem connections = new MenuItem("Connections:");
          connections.setEnabled(false);
          beanContextMenu.insert(connections, menuItemCount);
          menuItemCount++;
        }

        final Vector finalOutputs = outputBeans;

        for (int j = 0; j < esdV.size(); j++) {
          final int fj = j;
          String sourceBeanName = "";

          if (bc instanceof MetaBean) {
            Object sourceBean = ((BeanInstance) outputBeans.elementAt(j)).getBean();

            if (sourceBean instanceof WekaWrapper) {
              sourceBeanName = ((WekaWrapper) sourceBean).getWrappedAlgorithm()
                .getClass().getName();
            } else {
              sourceBeanName = sourceBean.getClass().getName();
            }

            sourceBeanName =
              sourceBeanName.substring(sourceBeanName.lastIndexOf('.') + 1,
                                       sourceBeanName.length());
            sourceBeanName += ": ";
          }

          EventSetDescriptor[] esds = (EventSetDescriptor[]) esdV.elementAt(j);

          for (int i = 0; i < esds.length; i++) {
            //    System.err.println(esds[i].getName());
            // add each event name to the menu
            //            JMenuItem evntItem = new JMenuItem(sourceBeanName
            //                                               +esds[i].getName());
            MenuItem evntItem = new MenuItem(sourceBeanName +
                                             esds[i].getName());
            final EventSetDescriptor esd = esds[i];

            // Check EventConstraints (if any) here
            boolean ok = true;

            if (bc instanceof EventConstraints) {
              ok = ((EventConstraints) bc).eventGeneratable(esd.getName());
            }

            if (ok) {
              evntItem.addActionListener(new ActionListener() {
                  public void actionPerformed(ActionEvent e) {
                    connectComponents(esd,
                                      (bc instanceof MetaBean)
                                      ? ((BeanInstance) finalOutputs.elementAt(fj)) : bi, xx, yy);
                    notifyIsDirty();
                  }
                });
            } else {
              evntItem.setEnabled(false);
            }

            beanContextMenu.add(evntItem);
            menuItemCount++;
          }
        }
      }
    } catch (IntrospectionException ie) {
      ie.printStackTrace();
    }

    //    System.err.println("Just before look for other options");
    // now look for other options for this bean
    if (bc instanceof UserRequestAcceptor) {
      Enumeration req = ((UserRequestAcceptor) bc).enumerateRequests();

      if (req.hasMoreElements()) {
        //  beanContextMenu.insert(new JLabel("Actions",
        //            SwingConstants.CENTER),
        //             menuItemCount);
        MenuItem actions = new MenuItem("Actions:");
        actions.setEnabled(false);
        beanContextMenu.insert(actions, menuItemCount);
        menuItemCount++;
      }

      while (req.hasMoreElements()) {
        String tempS = (String) req.nextElement();
        boolean disabled = false;

        // check to see if this item is currently disabled
        if (tempS.charAt(0) == '$') {
          tempS = tempS.substring(1, tempS.length());
          disabled = true;
        }

        final String tempS2 = tempS;

        //  JMenuItem custItem = new JMenuItem(tempS2);
        MenuItem custItem = new MenuItem(tempS2);
        custItem.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              ((UserRequestAcceptor) bc).performRequest(tempS2);
              notifyIsDirty();
            }
          });

        if (disabled) {
          custItem.setEnabled(false);
        }

        beanContextMenu.add(custItem);
        menuItemCount++;
      }
    }

    //    System.err.println("Just before showing menu");
    // popup the menu
    if (menuItemCount > 0) {
      //beanContextMenu.show(m_beanLayout, x, y);
      m_beanLayout.add(beanContextMenu);
      beanContextMenu.show(m_beanLayout, x, y);
    }
  }
View Full Code Here

    if (closestConnections.size() > 0) {
      int menuItemCount = 0;

      // modifications by Zerbetto
      //JPopupMenu deleteConnectionMenu = new JPopupMenu();
      PopupMenu deleteConnectionMenu = new PopupMenu();

      //      deleteConnectionMenu.insert(new JLabel("Delete Connection",
      //               SwingConstants.CENTER),
      //          menuItemCount);
      MenuItem deleteConnection = new MenuItem("Delete Connection:");
      deleteConnection.setEnabled(false);
      deleteConnectionMenu.insert(deleteConnection, menuItemCount);
      menuItemCount++;

      for (int i = 0; i < closestConnections.size(); i++) {
        final BeanConnection bc = (BeanConnection) closestConnections.elementAt(i);
        String connName = bc.getSourceEventSetDescriptor().getName();

        //JMenuItem deleteItem = new JMenuItem(connName);
        MenuItem deleteItem = new MenuItem(connName);
        deleteItem.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              bc.remove();
              m_beanLayout.revalidate();
              m_beanLayout.repaint();
              notifyIsDirty();
            }
          });
        deleteConnectionMenu.add(deleteItem);
        menuItemCount++;
      }

      //deleteConnectionMenu.show(m_beanLayout, x, y);
      m_beanLayout.add(deleteConnectionMenu);
      deleteConnectionMenu.show(m_beanLayout, x, y);
    }
  }
View Full Code Here

            bIsDownloading  = false;
            repaint();

            // set up our "Preferences" popup menu

            preferencesMenu = new PopupMenu();

            miAnimateMoves = new MenuItem("Turn Animation Off");
            miAnimateMoves.addActionListener(this);
            miAnimateMoves.setFont(new Font("Dialog", Font.PLAIN, 12));
View Full Code Here

    private void initTray() {
        if (SystemTray.isSupported()) {
            tray = SystemTray.getSystemTray();
            Image image = Toolkit.getDefaultToolkit().getImage("resources/busyicons/busy-icon0.png");
            PopupMenu popup = new PopupMenu();
           
            MenuItem openItem = new MenuItem("Open");
            openItem.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    System.out.println("show");
                    ParafiaView.this.getFrame().setVisible(true);
                }
            });
            popup.add(openItem);
           
            MenuItem exitItem = new MenuItem("Exit");
            exitItem.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    System.out.println("Exit");
                    System.exit(0);
                }
            });
            popup.add(exitItem);
           
            MenuItem hideItem = new MenuItem("Hide");
            hideItem.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    System.out.println("hide");
                    ParafiaView.this.getFrame().setVisible(false);
                }
            });
            popup.add(hideItem);
           
           
            trayIcon = new TrayIcon(image, "SystemTray Demo", popup);
            trayIcon.setImageAutoSize(true);
            try {
View Full Code Here

    SystemTray sysTray = SystemTray.getSystemTray();
    Image iconImage = Toolkit.getDefaultToolkit().getImage("icon.png");
   
    ExitActionListener exitListener = new ExitActionListener(ogThread, cfa635Thread);
   
    PopupMenu popupMenu = new PopupMenu();
    MenuItem exitItem = new MenuItem("Exit");
    exitItem.addActionListener(exitListener);
    popupMenu.add(exitItem);
   
    TrayIcon trayIcon = new TrayIcon(iconImage, "LFSLCD", popupMenu);
    trayIcon.setImageAutoSize(true);
   
    try {
View Full Code Here

TOP

Related Classes of java.awt.PopupMenu$AccessibleAWTPopupMenu

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.