Пример #1
0
  public void actionPerformed(ActionEvent event) {
    JMenuItem source = (JMenuItem) (event.getSource());

    for (GraphView v : gp.getGraphViewList()) {
      if (v.getMenuText().equals(source.getText())) {
        v.view();
        repaint();
        return;
      }
    }

    for (GraphDrawer d : gp.getGraphDrawerList()) {
      if (d.getMenuText().equals(source.getText())) {
        d.layout();
        repaint();
        return;
      }
    }

    for (GraphUtility u : gp.getGraphUtilityList()) {
      if (u.getMenuText().equals(source.getText())) {
        u.apply();
        repaint();
        return;
      }
    }

    for (GraphExperiment ge : gp.getGraphExperimentList()) {
      if (ge.getMenuText().equals(source.getText())) {
        ge.experiment();
        repaint();
        return;
      }
    }
  }
  public void testCreatesItemMenuWithItemsCorrectly() {
    _player.addItem(Item.BLOCKABALL);
    _player.addItem(Item.HEALVIAL);
    JMenu menu = _constructor.createItemMenu();
    assertNameAndText(menu, "Items", "Items");

    assertEquals("Number of menus was not correct", 3, menu.getItemCount());

    assertAllItemsHaveNames(menu);

    JMenuItem blockaballItemMenu = getWithName(menu, "BLOCKABALL");
    assertNotNull("Blockaball item menu was not added", blockaballItemMenu);
    assertEquals("Blockaball text was not right", "Blockaball", blockaballItemMenu.getText());
    assertNotNull("Blockaball action was not set", blockaballItemMenu.getAction());
    assertEquals(ItemAction.class, blockaballItemMenu.getAction().getClass());

    JMenuItem healVialItemMenu = getWithName(menu, "HEALVIAL");
    assertNotNull("HealVial item menu was not added", healVialItemMenu);
    assertEquals("HealVial text was not right", "Heal Vial", healVialItemMenu.getText());
    assertNotNull("HealVial action was not set", healVialItemMenu.getAction());
    assertEquals(ItemAction.class, healVialItemMenu.getAction().getClass());

    JMenuItem backItemMenu = getWithName(menu, "Back");
    assertNotNull("Back item menu was not added", backItemMenu);
    assertEquals("Back item text was not right", "Back", backItemMenu.getText());
    assertNotNull("Back action was not set", backItemMenu.getAction());
    assertEquals(BackAction.class, backItemMenu.getAction().getClass());
  }
  public void testCreatesTheItemShopMenu() {
    ItemShop building = new ItemShop();
    building.stockItems(Item.BLOCKABALL, Item.HEALVIAL);
    JMenu menu = _constructor.createBuildingMenu(building, null);

    Assert.assertNotNull(menu);
    Assert.assertEquals(building.getName(), menu.getName());
    Assert.assertEquals(building.getName(), menu.getText());
    Assert.assertEquals(2, menu.getItemCount());
    for (int i = 0; i < menu.getItemCount(); i++) {
      JMenuItem menuItem = menu.getItem(i);
      Action action = menuItem.getAction();
      Assert.assertNotNull(action);
      Assert.assertEquals(ItemAction.class, action.getClass());

      String name = menuItem.getName();
      if (name.equals(Item.BLOCKABALL.toString())) {
        Assert.assertEquals(Item.BLOCKABALL.getWellFormattedString(), menuItem.getText());
      } else if (name.equals(Item.HEALVIAL.toString())) {
        Assert.assertEquals(Item.HEALVIAL.getWellFormattedString(), menuItem.getText());
      } else {
        Assert.fail("Name: " + name + " Text: " + menuItem.getText());
      }
    }
  }
 /** {@inheritDoc} */
 @Override
 public void addMenuItemsWithExpansion(
     List<JMenuItem> menuItems,
     JMenu parentMenu,
     int maxItemsInMenu,
     ComponentFactory headerItemFactory) {
   if (menuItems.size() <= maxItemsInMenu) {
     // Just add them directly
     for (JMenuItem menuItem : menuItems) parentMenu.add(menuItem);
     return;
   }
   int index = 0;
   while (index < menuItems.size()) {
     int toIndex = min(menuItems.size(), index + maxItemsInMenu);
     if (toIndex == menuItems.size() - 1)
       // Don't leave a single item left for the last subMenu
       toIndex--;
     List<JMenuItem> subList = menuItems.subList(index, toIndex);
     JMenuItem firstItem = subList.get(0);
     JMenuItem lastItem = subList.get(subList.size() - 1);
     JMenu subMenu = new JMenu(firstItem.getText() + " ... " + lastItem.getText());
     if (headerItemFactory != null) subMenu.add(headerItemFactory.makeComponent());
     for (JMenuItem menuItem : subList) subMenu.add(menuItem);
     parentMenu.add(subMenu);
     index = toIndex;
   }
 }
  @Override
  public void actionPerformed(ActionEvent e) {
    JMenuItem item = (JMenuItem) e.getSource();

    if (item.getText().equals(DEFAULT_THEME)) {
      mainPanel.setBackground(Color.BLUE);
    } else if (item.getText().equals(CUSTOM_THEME)) {
      mainPanel.setBackground(Color.RED);
    }
  }
Пример #6
0
 public void actionPerformed(ActionEvent e) {
   JMenuItem source = (JMenuItem) (e.getSource());
   if (source.getText().equals("元に戻す")) {
     if (undo.canUndo()) {
       undo.undo();
     }
   } else if (source.getText().equals("やり直し")) {
     if (undo.canRedo()) {
       undo.redo();
     }
   }
 }
Пример #7
0
 public void newAccelerator(final JMenuItem editedItem, final KeyStroke newAccelerator) {
   final Object key = menuBuilder.getKeyByUserObject(editedItem);
   final String shortcutKey = menuBuilder.getShortcutKey(key.toString());
   final String oldShortcut = ResourceController.getResourceController().getProperty(shortcutKey);
   if (newAccelerator == null
       || !new KeystrokeValidator(editedItem, key, editedItem)
           .isValid(newAccelerator, newAccelerator.getKeyChar())) {
     final GrabKeyDialog grabKeyDialog = new GrabKeyDialog(oldShortcut);
     final IKeystrokeValidator validator = new KeystrokeValidator(grabKeyDialog, key, editedItem);
     grabKeyDialog.setValidator(validator);
     grabKeyDialog.setVisible(true);
     if (grabKeyDialog.isOK()) {
       final String shortcut = grabKeyDialog.getShortcut();
       final KeyStroke accelerator = UITools.getKeyStroke(shortcut);
       menuBuilder.setAccelerator((Node) menuBuilder.get(key), accelerator);
       ResourceController.getResourceController().setProperty(shortcutKey, shortcut);
       LogUtils.info(
           "created shortcut '"
               + shortcut
               + "' for menuitem '"
               + key
               + "', shortcutKey '"
               + shortcutKey
               + "' ("
               + editedItem.getText()
               + ")");
     }
   } else {
     if (oldShortcut != null) {
       final int replace =
           JOptionPane.showConfirmDialog(
               editedItem,
               oldShortcut,
               TextUtils.getText("remove_shortcut_question"),
               JOptionPane.YES_NO_OPTION);
       if (replace != JOptionPane.YES_OPTION) {
         return;
       }
     }
     menuBuilder.setAccelerator((Node) menuBuilder.get(key), newAccelerator);
     ResourceController.getResourceController().setProperty(shortcutKey, toString(newAccelerator));
     LogUtils.info(
         "created shortcut '"
             + toString(newAccelerator)
             + "' for menuitem '"
             + key
             + "', shortcutKey '"
             + shortcutKey
             + "' ("
             + editedItem.getText()
             + ")");
   }
 }
Пример #8
0
 @Override
 public void actionPerformed(ActionEvent e) {
   if (jItem.getText().equals("分词")) {
     frame.jPanel.removeAll();
     frame.jPanel.add(new AC_TypePanel());
     frame.jPanel.revalidate();
     frame.jPanel.repaint();
   }
   if (jItem.getText().equals("关键词")) {
     frame.jPanel.removeAll();
     frame.jPanel.add(new AC_KeywordPanel());
     frame.jPanel.revalidate();
     frame.jPanel.repaint();
   }
 }
  public void menuSelected(MenuEvent menuEvent) {
    // Remove previous menu items (if any)
    removeAll();

    if (BonjourDirectory.isActive()) {
      BonjourService services[] = BonjourDirectory.getServices();
      int nbServices = services.length;

      if (nbServices > 0) {
        // Add a menu item for each Bonjour service.
        // When clicked, the corresponding URL will opened in the active table.
        JMenuItem menuItem;
        MnemonicHelper mnemonicHelper = new MnemonicHelper();

        for (int i = 0; i < nbServices; i++) {
          menuItem = new JMenuItem(getMenuItemAction(services[i]));
          menuItem.setMnemonic(mnemonicHelper.getMnemonic(menuItem.getText()));

          add(menuItem);
        }
      } else {
        // Inform that no service have been discovered
        add(new JMenuItem(Translator.get("bonjour.no_service_discovered"))).setEnabled(false);
      }
    } else {
      // Inform that Bonjour support has been disabled
      add(new JMenuItem(Translator.get("bonjour.bonjour_disabled"))).setEnabled(false);
    }
  }
Пример #10
0
  public void printMenuElements(javax.swing.MenuElement[] subElements) {
    // System.out.println(tab+tab);
    //  System.out.println("See whether we are ever called.");

    for (int i = 0; i < subElements.length; i++) {

      if (subElements[i].getClass().getName() != "javax.swing.JPopupMenu") {

        // System.out.println("Element printing");

        javax.swing.JMenuItem abstractButton = (javax.swing.JMenuItem) subElements[i];

        //                System.out.println(subElements[i]);
        System.out.println(tabString + abstractButton.getText());
      }
      // System.out.println(abstractButton.getText());

      if (subElements[i].getSubElements().length > 0) {
        tabString = tabString + " ";

        // System.out.println("See this!");

        printMenuElements(subElements[i].getSubElements());

        // tabString = tabString + "\b";

      }

      // System.out.println("Element Closing");
    }

    tabString = tabString + "\b";
    //   System.out.println("Sub element closing");
    // }
  }
Пример #11
0
 public void actionPerformed(ActionEvent e) {
   if (e.getSource() instanceof JMenuItem) {
     JMenuItem item = (JMenuItem) e.getSource();
     String name = item.getText();
     profiles.delete(name);
   }
 }
  public void testCreatesBlockamonMenuCorrectly() {
    Blockamon blockamon = new Blockamon(ElementType.BUG);
    _player.addToParty(blockamon);
    JMenu menu = _constructor.createBlockamonMenu();

    assertNameAndText(menu, "Blockamon", "Blockamon");

    assertEquals("Number of menu items was not correct", 2, menu.getItemCount());

    JMenuItem blockamonMenuItem = menu.getItem(0);
    assertNameAndText(
        blockamonMenuItem,
        blockamon.elementType() + "0",
        blockamon.name()
            + ", "
            + blockamon.level()
            + ", "
            + blockamon.currentHp()
            + "/"
            + blockamon.maxHp());
    assertNotNull("Blockamon menu action not set", blockamonMenuItem.getAction());
    assertEquals(BlockamonAction.class, blockamonMenuItem.getAction().getClass());

    JMenuItem backItemMenu = menu.getItem(1);
    assertNotNull("Back item menu was not added", backItemMenu);
    assertEquals("Back item text was not right", "Back", backItemMenu.getText());
    assertNotNull("Back action was not set", backItemMenu.getAction());
    assertEquals(BackAction.class, backItemMenu.getAction().getClass());
  }
 /** actionPerformed */
 @Override
 public void actionPerformed(ActionEvent e) {
   JMenuItem menuItem = (JMenuItem) e.getSource();
   if (menuItem.getText().equals(recSwingApp.getTextoMenuItem(MENU_ITEM_SALIR))) acaba();
   else if (menuItem.getText().equals(recSwingApp.getTextoMenuItem(MENU_ITEM_ACERCA_DE))) {
     JOptionPane.showMessageDialog(
         this,
         recSwingApp.getGeneral(RecursosAppSwing.TITULO)
             + "\n"
             + recSwingApp.getGeneral(RecursosAppSwing.AUTOR)
             + "\n"
             + recSwingApp.getGeneral(RecursosAppSwing.VERSION),
         recSwingApp.getTextoMenuItem(MENU_ITEM_ACERCA_DE),
         JOptionPane.INFORMATION_MESSAGE,
         recSwingApp.getIconoApp());
   }
 }
Пример #14
0
  public int createTreeFromMenuBar(
      javax.swing.MenuElement subElements[],
      javax.swing.tree.DefaultMutableTreeNode treeNodes,
      javax.swing.tree.DefaultMutableTreeNode topReports,
      java.lang.String reportNodeTitle,
      java.lang.String utilitiesNodeTitle) {

    for (int i = 0; i < subElements.length; i++) {

      if (subElements[i].getClass().getName() != "javax.swing.JPopupMenu") {

        javax.swing.JMenuItem abstractButton = (javax.swing.JMenuItem) subElements[i];

        if (abstractButton.isEnabled()) {

          siblingNode = new javax.swing.tree.DefaultMutableTreeNode(abstractButton.getText());

          treeNodes.add(siblingNode);

          if (treeNodes.getUserObject() == "Reports") {

            treeNodes.setUserObject(reportNodeTitle);

            topReports.add(treeNodes);
          }

          if (treeNodes.getUserObject() == "Utility") {

            treeNodes.setUserObject(utilitiesNodeTitle);

            topReports.add(treeNodes);
          }
        }
      }

      if (subElements[i].getSubElements().length > 0) {

        createTreeFromMenuBar(
            subElements[i].getSubElements(),
            siblingNode,
            topReports,
            reportNodeTitle,
            utilitiesNodeTitle);

        if (treeNodes.isLeaf()) {

          javax.swing.tree.DefaultMutableTreeNode parentNode =
              (javax.swing.tree.DefaultMutableTreeNode) siblingNode.getParent();

          siblingNode.removeFromParent();
        }
      }

      treeCount++;
    }

    return treeCount;
  }
Пример #15
0
 private void selectModel(SubstitutionModel m) {
   manager.inputData.model = m;
   for (JMenuItem mi : modelButtons) {
     if (mi.getText().equals(m.getMenuName())) {
       mi.setSelected(true);
       break;
     }
   }
 }
Пример #16
0
  public void actionPerformed(ActionEvent e) {
    String cmd = (e.getActionCommand());

    if (cmd.equals(aboutItem.getText()))
      JOptionPane.showMessageDialog(
          this,
          "Simple Image Program for DB2004\nversion 0.1\nThanks to BvS",
          "About imageLab",
          JOptionPane.INFORMATION_MESSAGE);
    else if (cmd.equals(quitItem.getText())) System.exit(0);
    else if (cmd.equals(openItem.getText())) {
      int returnVal = chooser.showOpenDialog(this);
      if (returnVal == JFileChooser.APPROVE_OPTION) {
        try {
          pic2 = new Picture(chooser.getSelectedFile().getName());
          pic1 = new Picture(pic2.width(), pic2.height());
          lab.setIcon(pic2.getJLabel().getIcon());
          sliderPanel.setVisible(false);
          pack();
          repaint();
        } catch (Exception ex) {
          JOptionPane.showMessageDialog(
              this,
              "Could not open " + chooser.getSelectedFile().getName() + "\n" + ex.getMessage(),
              "Open Error",
              JOptionPane.INFORMATION_MESSAGE);
        }
      }

    } else if (cmd.equals(saveItem.getText())) {
      int returnVal = chooser.showSaveDialog(this);
      if (returnVal == JFileChooser.APPROVE_OPTION) {
        try {
          pic2.save(chooser.getSelectedFile().getName());
        } catch (Exception ex) {
          JOptionPane.showMessageDialog(
              this,
              "Could not write " + chooser.getSelectedFile().getName() + "\n" + ex.getMessage(),
              "Save Error",
              JOptionPane.INFORMATION_MESSAGE);
        }
      }
    }
  }
Пример #17
0
    public void actionPerformed(ActionEvent event) {

      JMenuItem mi;
      String label = "";

      if (warningPopup == null) {
        warningPopup = new WarningDialog(textViewerFrame);
      }
      if ((editor1 == null) || (editor1.getDocument() == null)) {
        String errstr = "TextViewer:editor1 or document is null";
        warningPopup.display(errstr);
        return;
      }
      String actionStr = event.getActionCommand(); // is not makeing anysense
      // when keystrokes typed
      if ((event.getSource() instanceof JMenuItem)) {
        mi = (JMenuItem) event.getSource();
        label = mi.getText();
      } else if ((event.getSource() instanceof JTextArea)) { // keystroke
        label = "FindAgain"; // just set it to findagain
      } else {
        System.err.println("Debug:TextViewer:" + actionStr);
        System.err.println("Debug:TextViewer:" + event.getSource().toString());
        String errstr =
            "TextViewer:FindAction: "
                + event.getSource().toString()
                + " not an instance of JMenuItem or JTextArea";
        warningPopup.display(errstr);
        return;
      }

      if (label.equals("FindAgain")) {
        isFindAgain = true;
        lastFindStr = lastFindStr;
      } else {
        isFindAgain = false;
        lastFindStr = "";
      }
      StringBoolean content = new StringBoolean(lastFindStr, forwardFindDirection);

      boolean okPressed = mySearchDialog.display(content);
      if (!okPressed) {
        return;
      }
      lastFindStr = content.mystring;
      forwardFindDirection = content.myboolean;

      if (forwardFindDirection) {
        lastFindIndex = searchForward(lastFindStr);
        //		System.out.println("Debug:TextViewer: lastFindIndex:"+lastFindIndex);

      } else {
        lastFindIndex = searchBackward(lastFindStr);
        //		System.out.println("Debug:TextViewer: lastFindIndex:"+lastFindIndex);
      }
    }
Пример #18
0
 public void actionPerformed(ActionEvent e) {
   JMenuItem jmi = (JMenuItem) e.getSource();
   Iterator marks = mediator.getMarkerModel().getMarkersWithLabel(jmi.getText());
   if (marks.hasNext()) {
     ChronicleMarker marker = (ChronicleMarker) marks.next();
     Instant to = marker.getWhen();
     Instant from = mediator.getMajorMoment();
     viper.api.impl.Util.shiftDescriptors(new Descriptor[] {desc}, from, to);
   }
 }
Пример #19
0
 public void actionPerformed(ActionEvent e) {
   super.actionPerformed(e);
   JMenuItem jmi = (JMenuItem) e.getSource();
   if (displayset.contains(jmi)) {
     mainPanel.setNames(jmi.getText());
   } else if (jmi == hiddenItem) {
     mainPanel.showIgnored(hiddenItem.isSelected());
   } else if (jmi == aggrItem) {
     mainPanel.showAggregates(aggrItem.isSelected());
   }
 }
Пример #20
0
 public void actionPerformed(ActionEvent e) {
   Iterator toInterp = Collections.singleton(desc).iterator();
   JMenuItem jmi = (JMenuItem) e.getSource();
   Iterator marks = mediator.getMarkerModel().getMarkersWithLabel(jmi.getText());
   if (marks.hasNext()) {
     ChronicleMarker marker = (ChronicleMarker) marks.next();
     Instant to = marker.getWhen();
     Instant from = mediator.getMajorMoment();
     mediator.getPropagator().interpolateDescriptors(toInterp, from, to);
   }
 }
Пример #21
0
  /* (non-Javadoc)
   * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
   */
  public void actionPerformed(ActionEvent e) {
    Object o = e.getSource();
    if (o instanceof JMenuItem) {
      JMenuItem sender = (JMenuItem) o;
      String name = sender.getText();
      if (name.equals("close")) {
        tabbedPane.removeTabAt(tabbedPane.getSelectedIndex());
      } else if (name.equals("save")) {
        int index = tabbedPane.getSelectedIndex();
        Component c = tabbedPane.getComponent(index);
        Point p = c.getLocation();
        Component t = tabbedPane.getComponentAt(new Point(p.x + 20, p.y + 30));
        if (t instanceof TextView) {
          TextView text = (TextView) t;
          // String code = text.getText();
          // save the code
          // saveTab(code);
        }
        if (t instanceof HTMLTextView) {
          HTMLTextView text = (HTMLTextView) t;
          fileChooser.setSelectedFile(new File(text.node.getName()));
          int returnVal = fileChooser.showSaveDialog(this);

          if (returnVal == JFileChooser.APPROVE_OPTION) {
            File f = fileChooser.getSelectedFile();

            // save the code
            String fileType =
                f.getName().substring(f.getName().lastIndexOf("."), f.getName().length());
            if (fileType.indexOf("htm") != -1) {
              // save as html
              String code = text.getText();
              saveTab(code, f);
            } else if (fileType.indexOf("java") != -1) {
              // save as java
              String code = text.getUnModyfiedContent();
              saveTab(code, f);
            } else if (text.node.fileType.indexOf(FileTypes.MANIFEST) != -1
                || text.node.fileType.indexOf(FileTypes.MANIFEST2) != -1) {
              String code = text.getUnModyfiedContent();
              saveTab(code, f);
              System.out.println("Saved manifest");
            } else {
              System.out.println("FILETYPE UNKNOWN:" + text.node.fileType);
            }
          }
        }
      } else if (name.equals("close all")) {
        tabbedPane.removeAll();
      }
    }
  }
Пример #22
0
 public void actionPerformed(ActionEvent e) {
   JMenuItem source = (JMenuItem) (e.getSource());
   String s =
       "Action event detected."
           + newline
           + "    Event source: "
           + source.getText()
           + " (an instance of "
           + getClassName(source)
           + ")";
   output.append(s + newline);
   output.setCaretPosition(output.getDocument().getLength());
 }
 public void actionPerformed(ActionEvent e) {
   JMenuItem item = (JMenuItem) e.getSource();
   // This should probably be done in AnnotationEditor changeSpStatus(gene,item...
   gene.addProperty("sp_status", item.getText());
   // AnnotationChangeEvent ace = AnnotationChangeEvent.getSessionDoneEvent(this);
   AnnotSessionDoneEvent de = new AnnotSessionDoneEvent(this);
   //     = new AnnotationChangeEvent(this,
   //                                 gene,
   //                                 FeatureChangeEvent.REDRAW,
   //                                 AnnotationChangeEvent.ANNOTATION,
   //                                 gene);
   getController().handleAnnotationChangeEvent(de);
 }
Пример #24
0
 private static void setEnabledAll(boolean isEnabled) {
   for (int i = 0; i < cadastreJMenu.getItemCount(); i++) {
     JMenuItem item = cadastreJMenu.getItem(i);
     if (item != null)
       if (item.getText().equals(MenuActionGrabPlanImage.name) /*||
                   item.getText().equals(MenuActionGrab.name) ||
                   item.getText().equals(MenuActionBoundaries.name) ||
                   item.getText().equals(MenuActionBuildings.name)*/) {
         item.setEnabled(isEnabled);
       }
   }
   menuEnabled = isEnabled;
 }
Пример #25
0
 @Override
 public void itemStateChanged(ItemEvent e) {
   if (LOG.isLoggable(Level.FINE)) {
     LOG.fine(" Received item state changed " + e.toString());
   }
   JMenuItem source = (JMenuItem) e.getSource();
   if ("Actor Details".equals(source.getText())) { // Show/hide the actor details panel
     boolean selected = (e.getStateChange() == ItemEvent.SELECTED);
     if (LOG.isLoggable(Level.FINER)) {
       LOG.finer("View/Actor Details item state changed. Selected = " + selected);
     }
     propertyBag.setProperty("Manager.actorDetails.visible", String.valueOf(selected));
     layoutActorPanel();
   } else if ("Auto-fit columns".equals(source.getText())) { // Auto-fit columns automatically
     boolean selected = (e.getStateChange() == ItemEvent.SELECTED);
     if (LOG.isLoggable(Level.FINER)) {
       LOG.finer("Tools/Auto-fit columns item state changed. Selected = " + selected);
     }
     propertyBag.setProperty("Manager.groupTable.autoResize", String.valueOf(selected));
     if (selected) groupTable.autoSizeColumns();
   }
 }
Пример #26
0
 public static void addFastKeys(JMenuBar menuBar) {
   for (Component menuComponent : menuBar.getComponents()) { // iterate over menus
     JMenu menu = (JMenu) menuComponent;
     menu.setMnemonic(menu.getText().charAt(menu.getText().indexOf('&') + 1));
     menu.setText(menu.getText().replace("&", ""));
     for (Component menuItemComponent : menu.getMenuComponents())
       if (menuItemComponent instanceof JMenuItem) { // skip separators
         JMenuItem menuItem = (JMenuItem) menuItemComponent;
         menuItem.setMnemonic(menuItem.getText().charAt(menuItem.getText().indexOf('&') + 1));
         menuItem.setText(menuItem.getText().replace("&", ""));
       }
     /*
     for (int count = 0; count < menu.getMenuComponentCount(); count++) {  //iterate over menu items
        Component menuItemComponent = menu.getMenuComponent(count);
        if (menuItemComponent instanceof JMenuItem) {   //skip separators
           JMenuItem menuItem = (JMenuItem)menuItemComponent;
           menuItem.setMnemonic(menuItem.getText().charAt(
                 menuItem.getText().indexOf('&') + 1));
           menuItem.setText(menuItem.getText().replace("&", ""));
           }
        }
     */
   }
 }
Пример #27
0
 public void itemStateChanged(ItemEvent e) {
   JMenuItem source = (JMenuItem) (e.getSource());
   String s =
       "Item event detected."
           + newline
           + "    Event source: "
           + source.getText()
           + " (an instance of "
           + getClassName(source)
           + ")"
           + newline
           + "    New state: "
           + ((e.getStateChange() == ItemEvent.SELECTED) ? "selected" : "unselected");
   output.append(s + newline);
   output.setCaretPosition(output.getDocument().getLength());
 }
Пример #28
0
  public void actionPerformed(ActionEvent arg0) {
    Object src = arg0.getSource();

    try {
      if (src instanceof JMenuItem) {
        JMenuItem item = (JMenuItem) src;
        String name = item.getText();

        if (name.equals("Properties")) {
          renderDialog.init();
          renderDialog.setVisible(true);
        }
      }
    } catch (Exception ex) {
      JOptionPane.showMessageDialog(this, ex.toString());
    }
  }
Пример #29
0
 public void actionPerformed(ActionEvent e) {
   if (e.getSource() instanceof JMenuItem) {
     JMenuItem item = (JMenuItem) e.getSource();
     String name = item.getText();
     Profile profile = profiles.getProfile(name);
     Component[] components = selectorPanel.getComponents();
     for (int i = 0; i < components.length; i++) {
       Component comp = components[i];
       if (comp instanceof CPCheckBox) {
         CPCheckBox scb = (CPCheckBox) comp;
         String id = scb.element.id;
         boolean enb = profile.has(id);
         scb.setState(enb);
       }
     }
   }
 }
Пример #30
0
  public void getTargetMenuItem(javax.swing.MenuElement[] subElements, java.lang.String treeNode) {

    java.lang.String string2search = treeNode;

    javax.swing.JMenuItem targetAbstractButton = null;

    for (int i = 0; i < subElements.length; i++) {

      if (subElements[i].getClass().getName() != "javax.swing.JPopupMenu") {

        // System.out.println("Element printing");

        javax.swing.JMenuItem abstractButton = (javax.swing.JMenuItem) subElements[i];

        //                System.out.println(subElements[i]);
        if (abstractButton.getText().equals(string2search)) {

          abstractButton.doClick();
          // targetAbstractButton = abstractButton;

          System.out.println("Printing corresponding menuitem : " + abstractButton);

          // break;

        }
      }
      // System.out.println(abstractButton.getText());

      if (subElements[i].getSubElements().length > 0) {
        tabString = tabString + " ";

        // System.out.println("See this!");

        getTargetMenuItem(subElements[i].getSubElements(), string2search);

        // tabString = tabString + "\b";

      }

      // System.out.println("Element Closing");
    }

    //   return targetAbstractButton;

  }