Package javax.swing

Examples of javax.swing.JMenuItem$MenuItemFocusListener


        return l;
    }

    public List getItemsForOMGraphicMenu(OMGraphic omg) {
        List l = new ArrayList();
        l.add(new JMenuItem("Which"));
        l.add(new JMenuItem("Why"));
        return l;
    }
View Full Code Here


        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"));
                          }
View Full Code Here

     * @param menu          The menu to add the action.
     * @param tag      The tag of the action to add.
     */
    private void addMenuItem(JMenu menu, String tag) {
        Action action = (Action) actions.get(tag);
        JMenuItem item = new JMenuItem(action);
        String s = getString(tag + "MnemonicIndex");
        if (s != null) {
            int i = getInt(tag + "MnemonicIndex");
            item.setDisplayedMnemonicIndex(i);
        }
        menu.add(item);
    }
View Full Code Here

     
      JMenuItem column_setup;
     
      public PopupListener() {
        
         column_setup = new JMenuItem("Column setup");
      }
     
      public void mousePressed(MouseEvent e) {
        showPopup(e);
      }
View Full Code Here

    fnew = new JMenu();
    view = new JMenu();
    tools = new JMenu();
    help = new JMenu();
    tabs = new JMenu();   
    exit = new JMenuItem();
    new_downloads = new JMenuItem();
    new_servers = new JMenuItem();
    import_server_list = new JMenuItem();
    ButtonGroup radio_button_menu_items_group = new ButtonGroup();
    servers = new JRadioButtonMenuItem();
    transfers = new JRadioButtonMenuItem();
    search = new JRadioButtonMenuItem();
    shared_files = new JRadioButtonMenuItem();
    stats = new JRadioButtonMenuItem();
    logs = new JRadioButtonMenuItem();
    radio_button_menu_items_group.add(servers);
    radio_button_menu_items_group.add(transfers);
    radio_button_menu_items_group.add(search);
    radio_button_menu_items_group.add(shared_files);
    radio_button_menu_items_group.add(stats);
    radio_button_menu_items_group.add(logs);
    servers.setSelected(true);
    ui_chooser = new JMenuItem();
    config_wizard = new JMenuItem();
    options = new JMenuItem();
        open_support = new JMenuItem();
        project_forums = new JMenuItem();
        bug_tracker = new JMenuItem();
        check_for_updates = new JMenuItem();
    about = new JMenuItem();
   
    tool_bar_visibility = new JCheckBoxMenuItem();
    status_bar_visibility = new JCheckBoxMenuItem();
    tool_bar_visibility.setText("Tool bar");
        status_bar_visibility.setText("Status bar");
View Full Code Here

     
      JMenuItem column_setup;
     
      public PopupListener() {
        
         column_setup = new JMenuItem("Column setup");
      }
View Full Code Here

          boolean locked = JSynoptic.gui.getLockedShapes().contains(provider);

          for (int i=0; i<actions.length; ++i) {
           
            // Display action in a hirarchical sub menus.
            JMenuItem jmi = createMenuItem(this, actions[i], null)//TODO Set icon if provided
           
           
            //JMenuItem jmi = new JMenuItem(actions[i]);
            if (locked || !provider.canDoAction(x,y,o,actions[i],context))
              jmi.setEnabled(false);
            else
              jmi.addActionListener(this);
           
            //add(jmi);
           
            menuItems.put(jmi, actions[i]);
            providers.put(jmi, provider);
          }
        }
      }
      if (obj instanceof Linkable) {
        final Linkable l = (Linkable)obj;
        final String link = l.getLink();
        if (!isEmpty) addSeparator();
        JMenuItem jmi;
        boolean followItem = false;
       
        if ((link==null) || (link.equals(""))) {
            jmi = new JMenuItem(messageWriter.print0args("AddLink"));
        } else {
            followItem = true;
            jmi = new JMenuItem(messageWriter.print0args("EditLink"));
        }

        jmi.addActionListener(this);
        menuItems.put(jmi, jmi.getText());
        add(jmi);
       
        providers.put(jmi, new ContextualActionProvider() {
          public String[] getActions(double x, double y, Object o, int context) {return null;}
          public boolean canDoAction(double x, double y, Object o, String action, int context) {return true;}
          public boolean doAction(double x, double y, Object o, String action, CompoundEdit undoableEdit) {

            JFileChooser fc;

            if(JSynoptic.gui instanceof JSynopticPanels){
              fc =((JSynopticPanels)JSynoptic.gui).getFileChooser();
            }else{
              fc = new JFileChooser();
            }
            if (link!=null) fc.setSelectedFile(new File(link));
            int res = fc.showDialog(JSynoptic.gui.getOwner(), messageWriter.print0args("SelectLink"));
            if (res!=JFileChooser.APPROVE_OPTION) return false;
            File f = fc.getSelectedFile();
            if ((f==null) || (!f.exists())) {
              JSynoptic.setStatus(messageWriter.print1args("CannotSetLinkInvalidFile",f.getName()));
              return false;
            }
            try {
              l.setLink(f.getCanonicalPath());
            } catch (IOException e) {
              l.setLink(f.getAbsolutePath());
            }
            ActionPopup.this.component.repaint();
            return true;
          }
        });
       
        if (followItem) {
           
            jmi = new JMenuItem(messageWriter.print0args("OpenLink"));
                    jmi.addActionListener(this);
                    menuItems.put(jmi, jmi.getText());
                    add(jmi);
           
            providers.put(jmi, new ContextualActionProvider() {
                public String[] getActions(double x, double y, Object o, int context) {return null;}
                public boolean canDoAction(double x, double y, Object o, String action, int context) {return true;}
View Full Code Here

   * @return
   */
  public static JMenuItem createMenuItem(JComponent currentMenu, String action, Icon icon){
    String[] subMenus = action.split(";");
    if (subMenus.length==1){
      JMenuItem item = new JMenuItem(subMenus[0], icon);
      currentMenu.add(item);
      return item;
    }else{
      String subMenu = subMenus[0];
      String suffix = action.substring(subMenu.length()+1);
View Full Code Here

  //
  //   ActionListener interface
  //
  public void actionPerformed(ActionEvent e) {
    if (!(e.getSource() instanceof JMenuItem)) return;
    JMenuItem jmi = (JMenuItem)e.getSource();
   
    String action = (String)menuItems.get(jmi);
    if (action==null) return;
   
    Object o = providers.get(jmi);
View Full Code Here

    }
    if (!found){
      jm = new JMenu(resources.getString("data"));
      mb.add(jm);
    }
    mergeItem= new JMenuItem(resources.getString("merge"));
    mergeItem.setIcon(resources.getIcon("mergeDataImage"));
   
    mergeItem.addActionListener(this);
    jm.add(mergeItem);
  }
View Full Code Here

TOP

Related Classes of javax.swing.JMenuItem$MenuItemFocusListener

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.