Package javax.swing

Examples of javax.swing.JPopupMenu


                    int index = list.locationToIndex(e.getPoint());
                    list.setSelectedIndex(index);
                }
               
                if (list.getSelectedIndex() > -1) {
                    JPopupMenu menu = getPopupMenu();               
                    menu.setInvoker(list);
                    menu.show(list, e.getX(), e.getY());
                }
            }

            if (e.getClickCount() == 2 && list.getSelectedIndex() > -1)
                open();
View Full Code Here


     (ActiveNode(child)).getParent() on to get the parent back, if needed.
     * @return A ready to use popup menu, or null if no child can be created for this parent. The menu
     * is ready to be shown, but the caller may add more entries if necessary.
     */
    public JPopupMenu getChildMenu(final ActiveNode parent, final ActionListener listener) {
        JPopupMenu ret = new JPopupMenu();
        Vector factories = getNodeFactoriesFor(parent);
        if (factories.size()==0) return null;
        Vector currentItems = new Vector();
        // Process all factories to build the popup menu
    for (Iterator it = factories.iterator(); it.hasNext();) {
        final NodeFactory nf = (NodeFactory)it.next();
        String type = nf.getNodeType();
          // Dispatch entries using the "|" separators to build sub-menus
        StringTokenizer st = new StringTokenizer(type,"|");
        for (int depth = 0; st.hasMoreTokens(); ++depth) {
            String token = st.nextToken();
            JMenuItem item;
            // If more token exists, then this entry is a submenu, not just a single item
            if (st.hasMoreTokens()) {
                  // If the menu already exists continue
                if ((depth<currentItems.size())
                && (currentItems.get(depth) instanceof JMenu)
                && ((JMenu)currentItems.get(depth)).getText().equals(token))
                    continue;
                  // The menu does not correspond. Create a new one
                  item = new JMenu(token);
            }
            // So, it is a single item, either the last item in the list, or a at top-level
            else {
                item = new JMenuItem(token);
                // This is a single item, it can lead to child creation => add the adequate listener
              item.addActionListener(new ActionListener() {
                      public void actionPerformed(ActionEvent e) {
                          ActiveNode child = nf.create(parent);
                          if(child!=null){
                            listener.actionPerformed(new ActionEvent(child,1,"childCreated"));
                          }
                      }
              });
            }
                if (depth==0) {
                    // first entry => use top-level popup menu
                    ret.add(item);
                    // Remove any item in the list
                    currentItems.clear();
                } else {
                    // previous item is menu by construction. Add this new item
                    ((JMenu)currentItems.get(depth-1)).add(item);
View Full Code Here

     
      private void showPopup(MouseEvent e) {
        
         if (e.isPopupTrigger()) {
          
           JPopupMenu popup_menu = new JPopupMenu();
         
           popup_menu.add(column_setup);
          
           popup_menu.show(e.getComponent(), e.getX(), e.getY());
         }
      } 
     
    }
   
View Full Code Here

     
      private void showPopup(MouseEvent e) {
        
         if (e.isPopupTrigger()) {
          
           JPopupMenu popup_menu = new JPopupMenu();
         
           popup_menu.add(column_setup);
          
           popup_menu.show(e.getComponent(), e.getX(), e.getY());
         }
      } 
View Full Code Here

      if (dest==null) dest = ((SceneGraphModel)sceneTree.getModel()).getRoot();
     
      if (!(dest instanceof ActiveNode)) return;
      ActiveNode node = (ActiveNode)dest;
     
      JPopupMenu menu = pluginManager.getChildMenu(node, this);
      List actions = node.getActions();
      if ((menu==null) && ((actions==null) || (actions.size()==0)))
          return; // this component does not have any declared potential children, and no actions
      // If there are actions, but no children, new menu
      if (menu==null) menu = new JPopupMenu();
      // Otherwise, add separator if needed
      else if ((actions!=null) && (actions.size()>0)) menu.add(new JPopupMenu.Separator(), 0);
      // Now add actions on top of menu, keeping order
      if (actions!=null)
          for (int i=actions.size()-1; i>=0; --i) {
              Object a = actions.get(i);
              if (a!=null) menu.add(new ActionMenuItem(node, a), 0);
          }
      // Finally popup the result
      menu.show((JComponent)e.getSource(), e.getX(), e.getY());
     
    } else if (e.getClickCount()==2 && (e.getModifiers()&MouseEvent.BUTTON1_MASK)==MouseEvent.BUTTON1_MASK){
     
      Object dest = null;
      TreePath path = sceneTree.getPathForLocation(e.getX(), e.getY());
View Full Code Here

        this(DataSourcePool.global);
    }

    protected void doPopup(int x, int y) {
        ShapesContainer sc = JSynoptic.gui.getActiveContainer();
        JPopupMenu popup;
        if (sc == null) {
            popup = new JPopupMenu();
        } else {
            DiagramComponent dc = sc.getComponent();
            if (dc == null) {
                return;
            }
            if (!(dc instanceof ShapesContainer.ShapesComponent)) {
                return;
            }
            ShapesContainer.ShapesComponent sco = (ShapesContainer.ShapesComponent) dc;
            if ((getSelectionPath() == null) && sco.isSelectionEmpty()) {
                JSynoptic.setStatus(messageWriter.print0args("noSelection"));
                return;
            }
            Point dcLoc = sco.getLocationOnScreen();
            Point myLoc = getLocationOnScreen();
            int sx = x + myLoc.x - dcLoc.x;
            int sy = y + myLoc.y - dcLoc.y;
            if (sco.isSelectionEmpty()) {
                popup = new JPopupMenu();
            } else {
                popup = sco.doPopup(sx, sy, ContextualActionProvider.SOURCELIST_CONTEXT);
                popup.addSeparator();
            }
        }
        if (sourceInfo == null) {
            sourceInfo = resources.getItem("sourceInfo", this);
        }
        popup.add(sourceInfo);
        if (sourceDelete == null) {
            sourceDelete = resources.getItem("sourceDelete", this);
        }
       
       
        Object o = getSelectedSourceOrCollection();
        if ( (o != null) && (!isLocked(o)) && selectionIsRootChild()) {
            popup.add(sourceDelete);
        }
     
        Object sel = getSelectedSourceOrCollection();
        if ((sel != null) && (sel instanceof ContextualActionProvider)) {
            ContextualActionProvider provider = (ContextualActionProvider) sel;
            String[] actions = provider.getActions(x, y, sel, ContextualActionProvider.SOURCELIST_CONTEXT);
            if ((actions != null) && (actions.length != 0)) {
                for (int i = 0; i < actions.length; ++i) {
                    JMenuItem jmi = new JMenuItem(actions[i]);
                    if (!provider.canDoAction(x, y, sel, actions[i], ContextualActionProvider.SOURCELIST_CONTEXT)) {
                        jmi.setEnabled(false);
                    } else {
                        jmi.addActionListener(this);
                    }
                    add(jmi);
                    popup.add(jmi);
                }
            }
        }
        actionX = y;
        actionY = y;
        popup.show(this, x, y);
    }
View Full Code Here

          }
        }
        if (actionDone) return; // stop there
      }
      if ((e.getModifiers() & MouseEvent.BUTTON3_MASK) == MouseEvent.BUTTON3_MASK) {
        JPopupMenu popup = doPopup(e.getX(), e.getY(), ContextualActionProvider.EDITOR_CONTEXT);
        if (popup==null) popup = new JPopupMenu();
        if (popup.getComponentCount()>0){
          popup.addSeparator();
        }
        boolean needSep=addCollectiveActions(popup, e.getX(), e.getY(), ContextualActionProvider.EDITOR_CONTEXT);
        if(getContextualDrawing()==null){
          if(needSep){
            popup.addSeparator();
          }
          if(JSynoptic.gui!=null)
            JSynoptic.gui.addEditMenu(popup);
        }
        if(getElementContainer().getSelection().isEmpty()){
          // no selection add background color menu
          popup.addSeparator();
          popup.add(new JMenuItem(new AbstractAction(
              resources.getStringValue("backgroundColorAction")) {
            public void actionPerformed(ActionEvent e) {
              Color c=showColorDialog(ShapesContainer.this._diagParam.backgr);
              if(c!=null){
                ShapesContainer.this._diagParam.backgr=c;
                ShapesContainer.this._diagParam.forgr=DiagramParameters.invertColor(c);
                repaint();
              }
            }
          }));
        }
        popup.show(this, e.getX(), e.getY());
      }
      super.mousePressed(e);
    }
View Full Code Here

      }
     
      private void showPopup(MouseEvent e) {
         if (e.isPopupTrigger()) {
          
           JPopupMenu popup_menu = null;
          
           switch( whichCondition() ) {
          
             case A : popup_menu = new JPopupMenu();
                    popup_menu.add(try_again);
                    popup_menu.add(copy_ed2k_links);
                    popup_menu.add(close);
                    popup_menu.add(column_setup);
                    popup_menu.add(properties);
                    break;
                   
             case B : popup_menu = new JPopupMenu();
                        popup_menu.add(try_again);
                        popup_menu.add(copy_ed2k_links);
                        popup_menu.add(close);
                        popup_menu.add(column_setup);
                        break;
                       
             case C : popup_menu = new JPopupMenu();
                        popup_menu.add(try_again);
                        popup_menu.add(copy_ed2k_links);
                        popup_menu.add(close);
                        popup_menu.add(column_setup);
                        popup_menu.add(properties);
                        break;
                       
             case D : popup_menu = new JPopupMenu();
                            popup_menu.add(try_again);
                            popup_menu.add(copy_ed2k_links);
                            popup_menu.add(close);
                            popup_menu.add(column_setup);
                            break;
                  
             case E : popup_menu = new JPopupMenu();
                      popup_menu.add(start_download);
                                popup_menu.add(try_again);
                                popup_menu.add(copy_ed2k_links);
                                popup_menu.add(close);
                                popup_menu.add(column_setup);
                                break;
                               
             case F : popup_menu = new JPopupMenu();
                          popup_menu.add(start_download);
                                popup_menu.add(try_again);
                                popup_menu.add(copy_ed2k_links);
                                popup_menu.add(close);
                                popup_menu.add(column_setup);
                                break;
                               
             case G : popup_menu = new JPopupMenu();
                          popup_menu.add(start_download);
                                popup_menu.add(try_again);
                                popup_menu.add(copy_ed2k_links);
                                popup_menu.add(close);
                                popup_menu.add(column_setup);
                                break;
                               
             case H : popup_menu = new JPopupMenu();
                              popup_menu.add(start_download);
                                popup_menu.add(try_again);
                                popup_menu.add(copy_ed2k_links);
                                popup_menu.add(close);
                                popup_menu.add(column_setup);
                                popup_menu.add(properties);
                                break;
                               
             case I : popup_menu = new JPopupMenu();
                                popup_menu.add(start_download);
                                popup_menu.add(try_again);
                                popup_menu.add(copy_ed2k_links);
                                popup_menu.add(close);
                                popup_menu.add(column_setup);
                                break;
                               
             case J : popup_menu = new JPopupMenu();
                      popup_menu.add(close);
                      popup_menu.add(column_setup);
                      break;
              
           }
           popup_menu.show(e.getComponent(), e.getX(), e.getY());
         }
      }
    }
    this.addMouseListener(new PopupListener());
  }
View Full Code Here

      }
     
      private void showPopup(MouseEvent e) {
         if (e.isPopupTrigger()) {
          
           JPopupMenu popup_menu = null;
          
           switch( whichCondition() ) {
          
             case A : popup_menu = new JPopupMenu();
                    popup_menu.add(try_again);
                    popup_menu.add(copy_ed2k_links);
                    popup_menu.add(close);
                    popup_menu.add(column_setup);
                    popup_menu.add(properties);
                    break;
                   
             case B : popup_menu = new JPopupMenu();
                        popup_menu.add(try_again);
                        popup_menu.add(copy_ed2k_links);
                        popup_menu.add(close);
                        popup_menu.add(column_setup);
                        break;
                       
             case C : popup_menu = new JPopupMenu();
                        popup_menu.add(try_again);
                        popup_menu.add(copy_ed2k_links);
                        popup_menu.add(close);
                        popup_menu.add(column_setup);
                        popup_menu.add(properties);
                        break;
                       
             case D : popup_menu = new JPopupMenu();
                            popup_menu.add(try_again);
                            popup_menu.add(copy_ed2k_links);
                            popup_menu.add(close);
                            popup_menu.add(column_setup);
                            break;
                  
             case E : popup_menu = new JPopupMenu();
                      popup_menu.add(start_download);
                                popup_menu.add(try_again);
                                popup_menu.add(copy_ed2k_links);
                                popup_menu.add(close);
                                popup_menu.add(column_setup);
                                break;
                               
             case F : popup_menu = new JPopupMenu();
                          popup_menu.add(start_download);
                                popup_menu.add(try_again);
                                popup_menu.add(copy_ed2k_links);
                                popup_menu.add(close);
                                popup_menu.add(column_setup);
                                break;
                               
             case G : popup_menu = new JPopupMenu();
                          popup_menu.add(start_download);
                                popup_menu.add(try_again);
                                popup_menu.add(copy_ed2k_links);
                                popup_menu.add(close);
                                popup_menu.add(column_setup);
                                break;
                               
             case H : popup_menu = new JPopupMenu();
                              popup_menu.add(start_download);
                                popup_menu.add(try_again);
                                popup_menu.add(copy_ed2k_links);
                                popup_menu.add(close);
                                popup_menu.add(column_setup);
                                popup_menu.add(properties);
                                break;
                               
             case I : popup_menu = new JPopupMenu();
                                popup_menu.add(start_download);
                                popup_menu.add(try_again);
                                popup_menu.add(copy_ed2k_links);
                                popup_menu.add(close);
                                popup_menu.add(column_setup);
                                break;
                               
             case J : popup_menu = new JPopupMenu();
                      popup_menu.add(close);
                      popup_menu.add(column_setup);
                      break;
              
           }
           popup_menu.show(e.getComponent(), e.getX(), e.getY());
         }
      }
View Full Code Here

      UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (Exception evt) {
      evt.printStackTrace();
    }

    JPopupMenu menu = new JPopupMenu();
    JMenuItem item;

    item = new JMenuItem(mLocalizer.msg("search", "Search"));
    item.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent evt) {
        DesktopToolkit.openPageInBrowser("searchinput.jsp");
      }
    });
    menu.add(item);

    item = new JMenuItem(mLocalizer.msg("status", "Status"));
    item.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent evt) {
        DesktopToolkit.openPageInBrowser("status.jsp");
      }
    });
    menu.add(item);
   
    item = new JMenuItem(mLocalizer.msg("config", "Preferences"));
    item.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent evt) {
        DesktopToolkit.openPageInBrowser("config.jsp");
      }
    });
    menu.add(item);

    menu.addSeparator();
   
    item = new JMenuItem(mLocalizer.msg("exit", "Exit"));
    item.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent evt) {
        Main.quit();
      }
    });
    menu.add(item);
   
    ImageIcon icon = new ImageIcon(getClass().getResource("regain_icon_16.gif"));

    // NOTE: The SystemTray must be created get before the TrayIcon is created.
    //       Otherwise a UnsatisfiedLinkError will raise on linux systems
View Full Code Here

TOP

Related Classes of javax.swing.JPopupMenu

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.