Package javax.swing

Examples of javax.swing.JMenu


   */
  private void addTimeInfoMenu() {
    JComponent time;

    if (Settings.propTrayOnTimeProgramsInSubMenu.getBoolean()) {
      time = new JMenu(mLocalizer.msg("menu.programsAtTime", "Programs at time"));
      mTrayMenu.add(time);
    } else {
      time = mTrayMenu;
    }

    int[] tempTimes = Settings.propTimeButtons.getIntArray();

    ArrayList<Integer> today = new ArrayList<Integer>();
    ArrayList<Integer> tomorrow = new ArrayList<Integer>();

    for (int tempTime : tempTimes) {
      if (tempTime < IOUtilities.getMinutesAfterMidnight()) {
        tomorrow.add(tempTime);
      } else {
        today.add(tempTime);
      }
    }

    int[] times;

    if (tomorrow.isEmpty() || today.isEmpty()) {
      times = tempTimes;
    } else {
      times = new int[tempTimes.length + 1];

      int j = 0;

      for (int i = 0; i < today.size(); i++) {
        times[j] = today.get(i).intValue();
        j++;
      }

      times[j] = -1;
      j++;

      for (int i = 0; i < tomorrow.size(); i++) {
        times[j] = tomorrow.get(i).intValue();
        j++;
      }
    }

    for (int value : times) {
      if (value == -1) {
        if (time instanceof JMenu) {
          ((JMenu) time).addSeparator();
        } else {
          ((JPopupMenu) time).addSeparator();
        }
      } else {
        final int fvalue = value;

        final JMenu menu = new ScrollableMenu(IOUtilities.timeToString(value) + " "
            + (mTime24 ? mLocalizer.msg("menu.time", "") : ""));

        if (value < IOUtilities.getMinutesAfterMidnight()) {
          menu.setText(menu.getText() + " " + mLocalizer.msg("menu.tomorrow", ""));
        }

        menu.addMenuListener(new MenuListener() {
          public void menuSelected(MenuEvent e) {
            createTimeProgramMenu(menu, fvalue);
          }

          public void menuCanceled(MenuEvent e) {
View Full Code Here


   * Creates the Plugin-Menus
   *
   * @return Plugin-Menu
   */
  private static JMenu createPluginsMenu() {
    JMenu pluginsMenu = new JMenu(mLocalizer.msg("menu.plugins", "Plugins"));

    PluginProxy[] plugins = PluginProxyManager.getInstance().getActivatedPlugins();
    updatePluginsMenu(pluginsMenu, plugins);

    return pluginsMenu;
View Full Code Here

    } else {
      visMargin.setEnabled(false);
    }
    resultListMenu.add(visMargin);

    JMenu visThreshold = new JMenu("Visualize threshold curve");
    if ((preds != null) && (classAtt != null) && (classAtt.isNominal())) {
      for (int i = 0; i < classAtt.numValues(); i++) {
  JMenuItem clv = new JMenuItem(classAtt.value(i));
  final int classValue = i;
  clv.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        try {
    ThresholdCurve tc = new ThresholdCurve();
    Instances result = tc.getCurve(preds, classValue);
    //VisualizePanel vmc = new VisualizePanel();
    ThresholdVisualizePanel vmc = new ThresholdVisualizePanel();
    vmc.setROCString("(Area under ROC = " +
         Utils.doubleToString(ThresholdCurve.getROCArea(result), 4) + ")");
    vmc.setLog(m_Log);
    vmc.setName(result.relationName()+". (Class value "+
          classAtt.value(classValue)+")");
    PlotData2D tempd = new PlotData2D(result);
    tempd.setPlotName(result.relationName());
    tempd.addInstanceNumberAttribute();
    // specify which points are connected
    boolean[] cp = new boolean[result.numInstances()];
    for (int n = 1; n < cp.length; n++)
      cp[n] = true;
    tempd.setConnectPoints(cp);
    // add plot
    vmc.addPlot(tempd);
    visualizeClassifierErrors(vmc);
        } catch (Exception ex) {
    ex.printStackTrace();
        }
        }
    });
    visThreshold.add(clv);
      }
    } else {
      visThreshold.setEnabled(false);
    }
    resultListMenu.add(visThreshold);
   
    JMenu visCostBenefit = new JMenu("Cost/Benefit analysis");
    if ((preds != null) && (classAtt != null) && (classAtt.isNominal())) {
      for (int i = 0; i < classAtt.numValues(); i++) {
        JMenuItem clv = new JMenuItem(classAtt.value(i));
        final int classValue = i;
        clv.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              try {
                ThresholdCurve tc = new ThresholdCurve();
                Instances result = tc.getCurve(preds, classValue);

                // Create a dummy class attribute with the chosen
                // class value as index 0 (if necessary).
                Attribute classAttToUse = classAtt;
                if (classValue != 0) {
                  FastVector newNames = new FastVector();
                  newNames.addElement(classAtt.value(classValue));
                  for (int k = 0; k < classAtt.numValues(); k++) {
                    if (k != classValue) {
                      newNames.addElement(classAtt.value(k));
                    }
                  }
                  classAttToUse = new Attribute(classAtt.name(), newNames);
                }
               
                CostBenefitAnalysis cbAnalysis = new CostBenefitAnalysis();
               
                PlotData2D tempd = new PlotData2D(result);
                tempd.setPlotName(result.relationName());
                tempd.m_alwaysDisplayPointsOfThisSize = 10;
                // specify which points are connected
                boolean[] cp = new boolean[result.numInstances()];
                for (int n = 1; n < cp.length; n++)
                  cp[n] = true;
                tempd.setConnectPoints(cp);
               
                String windowTitle = "";
                if (classifier != null) {
                  String cname = classifier.getClass().getName();
                  if (cname.startsWith("weka.classifiers.")) {
                    windowTitle = "" + cname.substring("weka.classifiers.".length()) + " ";
                  }
                }
                windowTitle += " (class = " + classAttToUse.value(0) + ")";               
               
                // add plot
                cbAnalysis.setCurveData(tempd, classAttToUse);
                visualizeCostBenefitAnalysis(cbAnalysis, windowTitle);
              } catch (Exception ex) {
                ex.printStackTrace();
              }
              }
          });
          visCostBenefit.add(clv);
      }
    } else {
      visCostBenefit.setEnabled(false);
    }
    resultListMenu.add(visCostBenefit);

    JMenu visCost = new JMenu("Visualize cost curve");
    if ((preds != null) && (classAtt != null) && (classAtt.isNominal())) {
      for (int i = 0; i < classAtt.numValues(); i++) {
  JMenuItem clv = new JMenuItem(classAtt.value(i));
  final int classValue = i;
  clv.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        try {
    CostCurve cc = new CostCurve();
    Instances result = cc.getCurve(preds, classValue);
    VisualizePanel vmc = new VisualizePanel();
    vmc.setLog(m_Log);
    vmc.setName(result.relationName()+". (Class value "+
          classAtt.value(classValue)+")");
    PlotData2D tempd = new PlotData2D(result);
    tempd.m_displayAllPoints = true;
    tempd.setPlotName(result.relationName());
    boolean [] connectPoints =
      new boolean [result.numInstances()];
    for (int jj = 1; jj < connectPoints.length; jj+=2) {
      connectPoints[jj] = true;
    }
    tempd.setConnectPoints(connectPoints);
    //      tempd.addInstanceNumberAttribute();
    vmc.addPlot(tempd);
    visualizeClassifierErrors(vmc);
        } catch (Exception ex) {
    ex.printStackTrace();
        }
      }
    });
  visCost.add(clv);
      }
    } else {
      visCost.setEnabled(false);
    }
    resultListMenu.add(visCost);
   
    // visualization plugins
    JMenu visPlugins = new JMenu("Plugins");
    boolean availablePlugins = false;
   
    // predictions
    Vector pluginsVector = GenericObjectEditor.getClassnames(VisualizePlugin.class.getName());
    for (int i = 0; i < pluginsVector.size(); i++) {
      String className = (String) (pluginsVector.elementAt(i));
      try {
        VisualizePlugin plugin = (VisualizePlugin) Class.forName(className).newInstance();
        if (plugin == null)
          continue;
        availablePlugins = true;
        JMenuItem pluginMenuItem = plugin.getVisualizeMenuItem(preds, classAtt);
        Version version = new Version();
        if (pluginMenuItem != null) {
          /*if (version.compareTo(plugin.getMinVersion()) < 0)
            pluginMenuItem.setText(pluginMenuItem.getText() + " (weka outdated)");
          if (version.compareTo(plugin.getMaxVersion()) >= 0)
            pluginMenuItem.setText(pluginMenuItem.getText() + " (plugin outdated)"); */
          visPlugins.add(pluginMenuItem);
        }
      }
      catch (Exception e) {
    //e.printStackTrace();
      }
    }
   
    // errros
    pluginsVector = GenericObjectEditor.getClassnames(ErrorVisualizePlugin.class.getName());
    for (int i = 0; i < pluginsVector.size(); i++) {
      String className = (String) (pluginsVector.elementAt(i));
      try {
        ErrorVisualizePlugin plugin = (ErrorVisualizePlugin) Class.forName(className).newInstance();
        if (plugin == null)
          continue;
        availablePlugins = true;
        JMenuItem pluginMenuItem = plugin.getVisualizeMenuItem(vp.getInstances());
        Version version = new Version();
        if (pluginMenuItem != null) {
          /*if (version.compareTo(plugin.getMinVersion()) < 0)
            pluginMenuItem.setText(pluginMenuItem.getText() + " (weka outdated)");
          if (version.compareTo(plugin.getMaxVersion()) >= 0)
            pluginMenuItem.setText(pluginMenuItem.getText() + " (plugin outdated)"); */
          visPlugins.add(pluginMenuItem);
        }
      }
      catch (Exception e) {
    //e.printStackTrace();
      }
    }
   
    // graphs+trees
    if (grph != null) {
      // trees
      if (((Drawable) temp_classifier).graphType() == Drawable.TREE) {
  pluginsVector = GenericObjectEditor.getClassnames(TreeVisualizePlugin.class.getName());
  for (int i = 0; i < pluginsVector.size(); i++) {
    String className = (String) (pluginsVector.elementAt(i));
    try {
      TreeVisualizePlugin plugin = (TreeVisualizePlugin) Class.forName(className).newInstance();
      if (plugin == null)
        continue;
      availablePlugins = true;
      JMenuItem pluginMenuItem = plugin.getVisualizeMenuItem(grph, selectedName);
      Version version = new Version();
      if (pluginMenuItem != null) {
        /*if (version.compareTo(plugin.getMinVersion()) < 0)
    pluginMenuItem.setText(pluginMenuItem.getText() + " (weka outdated)");
        if (version.compareTo(plugin.getMaxVersion()) >= 0)
    pluginMenuItem.setText(pluginMenuItem.getText() + " (plugin outdated)"); */
        visPlugins.add(pluginMenuItem);
      }
    }
    catch (Exception e) {
      //e.printStackTrace();
    }
  }
      }
      // graphs
      else {
  pluginsVector = GenericObjectEditor.getClassnames(GraphVisualizePlugin.class.getName());
  for (int i = 0; i < pluginsVector.size(); i++) {
    String className = (String) (pluginsVector.elementAt(i));
    try {
      GraphVisualizePlugin plugin = (GraphVisualizePlugin) Class.forName(className).newInstance();
      if (plugin == null)
        continue;
      availablePlugins = true;
      JMenuItem pluginMenuItem = plugin.getVisualizeMenuItem(grph, selectedName);
      Version version = new Version();
      if (pluginMenuItem != null) {
        /*if (version.compareTo(plugin.getMinVersion()) < 0)
    pluginMenuItem.setText(pluginMenuItem.getText() + " (weka outdated)");
        if (version.compareTo(plugin.getMaxVersion()) >= 0)
    pluginMenuItem.setText(pluginMenuItem.getText() + " (plugin outdated)"); */
        visPlugins.add(pluginMenuItem);
      }
    }
    catch (Exception e) {
      //e.printStackTrace();
    }
View Full Code Here

  /**
   * Init the session menu.
   */
  private void initSessionMenu() {
    sessionMenu = new JMenu(this.properties.getValue("sessionMenu"));
    JMenuItem openSession = new JMenuItem(properties.getValue("openSession"));
    JMenuItem closeSession = new JMenuItem(properties.getValue("closeSession"));
    JMenuItem exit = new JMenuItem(properties.getValue("exit"));

    exit.addActionListener(new QuitAppli());
View Full Code Here

  /**
   * Init the option menu.
   */
  private void initOptionsMenu() {
    optionsMenu = new JMenu(this.properties.getValue("optionsMenu"));
    JMenuItem options = new JMenuItem(properties.getValue("options"));
    JMenuItem help = new JMenuItem(properties.getValue("help"));
    JMenuItem about = new JMenuItem(properties.getValue("about"));

    options.addActionListener(new SetOptions(this.properties, MainFrame.myRef));
View Full Code Here

    mChGoToURL = new JMenuItem(mLocalizer.msg("openURL", "Open internet page"),
        IconLoader.getInstance().getIconFromTheme("apps",
            "internet-web-browser"));

    // dynamically create filters from available channel filter components
    mFilterChannels = new JMenu(mLocalizer.msg("filterChannels",
        "Channel filter"));
    MainFrame.getInstance().updateChannelGroupMenu(mFilterChannels);

    mChAdd.addActionListener(this);
    mChConf.addActionListener(this);
    mChGoToURL.addActionListener(this);

    mMenu.add(mChGoToURL);
    if (ChannelList.isSubscribedChannel(ch)) {
      mMenu.add(mChConf);
    }
    if (!(mSource instanceof ChannelsSettingsTab)) {
      mMenu.add(mFilterChannels);
      mMenu.addSeparator();
      mMenu.add(mChAdd);
      JMenu configureLayout = new JMenu(mLocalizer.msg("layout", "Layout"));
      layoutBoth = new JRadioButtonMenuItem(mLocalizer.msg("layoutBoth",
          "Logo and name"));
      layoutLogo = new JRadioButtonMenuItem(mLocalizer
          .msg("layoutLogo", "Logo"));
      layoutName = new JRadioButtonMenuItem(mLocalizer
          .msg("layoutName", "Name"));
      configureLayout.add(layoutBoth);
      configureLayout.add(layoutLogo);
      configureLayout.add(layoutName);
      mMenu.add(configureLayout);

      layoutBoth.addActionListener(this);
      layoutLogo.addActionListener(this);
      layoutName.addActionListener(this);
View Full Code Here

    frmEverbox.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
   
    JMenuBar menuBar = new JMenuBar();
    frmEverbox.setJMenuBar(menuBar);
   
    JMenu FileMenu = new JMenu("File");
    menuBar.add(FileMenu);
   
    JMenuItem ExitMenuItem = new JMenuItem("\u9000\u51FA");
    ExitMenuItem.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        client.run = false;
        stopClientButton.setText("正在关闭,请等候");
        while(true) {
          if(clientThread.isAlive())
            try {
              Thread.sleep(1000);
            } catch (Throwable e1) {
            }
          break;
        }
        frmEverbox.dispose();
      }
    });
    FileMenu.add(ExitMenuItem);
   
    JMenu cleanMenu = new JMenu("\u6E05\u7406");
    menuBar.add(cleanMenu);
   
    JMenuItem mntmNewMenuItem = new JMenuItem("\u6E05\u7406\u767B\u9646\u4FE1\u606F");
    mntmNewMenuItem.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        File f = new File("everbox.data");
        if(f.exists())
          f.delete();
      }
    });
    mntmNewMenuItem.setEnabled(false);
    cleanMenu.add(mntmNewMenuItem);
   
    JMenuItem mntmNewMenuItem_1 = new JMenuItem("\u6E05\u7406\u65E5\u5FD7\u4FE1\u606F");
    mntmNewMenuItem_1.setEnabled(false);
    cleanMenu.add(mntmNewMenuItem_1);
   
    JMenuItem mntmNewMenuItem_3 = new JMenuItem("\u6E05\u7406\u4E0B\u8F7D\u7528\u5230\u7684\u4E34\u65F6\u6587\u4EF6");
    mntmNewMenuItem_3.setEnabled(false);
    cleanMenu.add(mntmNewMenuItem_3);
   
    JMenuItem mntmNewMenuItem_4 = new JMenuItem("\u6E05\u7406\u6587\u4EF6\u6570\u636E\u5E93");
    mntmNewMenuItem_4.setEnabled(false);
    cleanMenu.add(mntmNewMenuItem_4);
   
    JMenu helpMenu = new JMenu("\u5E2E\u52A9");
    menuBar.add(helpMenu);
   
    JMenuItem vistHomepageMenuItem = new JMenuItem("\u8BBF\u95EE\u9879\u76EE\u9996\u9875");
    vistHomepageMenuItem.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        try {
          Desktop.getDesktop().browse(new URL("http://everbox4j.googlecode.com").toURI());
        } catch (Throwable e2) {
          log.warn("启动浏览器失败!!",e2);
          JOptionPane.showConfirmDialog(frmEverbox, "启动浏览器失败!! http://everbox4j.googlecode.com");
        }
      }
    });
    helpMenu.add(vistHomepageMenuItem);
   
    JMenuItem sendMailFeedback = new JMenuItem("\u610F\u89C1\u53CD\u9988(\u53D1\u9001\u90AE\u4EF6)");
    sendMailFeedback.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        try {
          Desktop.getDesktop().mail(new URL("everbox4j@wendal.net").toURI());
        } catch (Throwable e2) {
          log.warn("启动邮件客户端失败!!",e2);
          JOptionPane.showConfirmDialog(frmEverbox, "启动邮件客户端失败!! 反馈邮箱: everbox4j@wendal.net");
        }
      }
    });
    helpMenu.add(sendMailFeedback);
   
    JMenuItem aboutMenuItem = new JMenuItem("\u5173\u4E8E...");
    aboutMenuItem.setEnabled(false);
    helpMenu.add(aboutMenuItem);
   
    JPanel clientContrlPanel = new JPanel();
    frmEverbox.getContentPane().add(clientContrlPanel, BorderLayout.NORTH);
   
    JLabel label = new JLabel("\u8FD0\u884C\u72B6\u6001");
View Full Code Here

    menu.add(getExportMenu(mPaths[0]));

    menu.addSeparator();

    JMenu menus = ContextMenuManager.getInstance().createContextMenuItems(null, mPrograms[0], false);

    Component[] comps = menus.getMenuComponents();
    for (Component comp : comps) {
      menu.add(comp);
      comp.setEnabled(mPrograms.length == 1);
    }
View Full Code Here

   * @param paths create action for this TreePath
   */
  protected JMenu getExportMenu(TreePath paths) {
    final Node node = (Node) paths.getLastPathComponent();

    JMenu menu = new JMenu(mLocalizer.msg("export","Export"));
    menu.setFont(MenuUtil.CONTEXT_MENU_PLAINFONT);

    if ((node.getChildCount() == 0) && (node.getType() != Node.PROGRAM)) {
      menu.setEnabled(false);
      return menu;
    }

    Object o = getObjectForNode(node);
    Plugin currentPlugin = null;

    if(o instanceof Plugin) {
      currentPlugin = (Plugin)o;
    }

    for (InternalPluginProxyIf internalProxy : InternalPluginProxyList.getInstance().getAvailableProxys()) {
      if (internalProxy instanceof ProgramReceiveIf) {
        final ProgramReceiveIf receiveProxy = (ProgramReceiveIf) internalProxy;
        if(receiveProxy.canReceiveProgramsWithTarget() && o != internalProxy) {
          final ProgramReceiveTarget target = receiveProxy.getProgramReceiveTargets()[0];
          JMenuItem item = new JMenuItem(target.getTargetName());
          item.setFont(MenuUtil.CONTEXT_MENU_PLAINFONT);
          item.setIcon(internalProxy.getIcon());
          menu.add(item);
          item.addActionListener(new ActionListener(){
            public void actionPerformed(ActionEvent e) {
              Program[] programs = collectProgramsFromNode(node);
              if ((programs != null) &&(programs.length > 0)) {
                receiveProxy.receivePrograms(programs, target);
              }
            }
          });
        }
      }
    }

    PluginProxy[] plugins = PluginProxyManager.getInstance().getActivatedPlugins();
    for (final PluginProxy plugin : plugins) {
     if ((plugin.canReceiveProgramsWithTarget())
          && plugin.getProgramReceiveTargets() != null
          && plugin.getProgramReceiveTargets().length > 0) {
        if ((currentPlugin == null) || (!currentPlugin.getId().equals(plugin.getId()))) {
          ProgramReceiveTarget[] targets = plugin.getProgramReceiveTargets();
          if (!plugin.canReceiveProgramsWithTarget()) {
            JMenuItem item = new JMenuItem(plugin.getInfo().getName());
            item.setFont(MenuUtil.CONTEXT_MENU_PLAINFONT);

            Icon icon = plugin.getPluginIcon();

            item.setIcon(icon != null ? icon : null);
            menu.add(item);
            item.addActionListener(new ActionListener() {
              public void actionPerformed(ActionEvent e) {
                Program[] programs = collectProgramsFromNode(node);
                if ((programs != null) && (programs.length > 0)) {
                  plugin.receivePrograms(programs, ProgramReceiveTarget.createDefaultTargetForProgramReceiveIfId(plugin.getId()));
                }
              }
            });
          } else if (targets.length == 1 && (!(o instanceof ProgramReceiveTarget) || !o.equals(targets[0]))) {
            JMenuItem item = new JMenuItem(targets[0].toString());
            item.setFont(MenuUtil.CONTEXT_MENU_PLAINFONT);

            Icon icon = plugin.getPluginIcon();

            item.setIcon(icon != null ? icon : null);
            menu.add(item);

            final ProgramReceiveTarget target = targets[0];

            item.addActionListener(new ActionListener() {
              public void actionPerformed(ActionEvent e) {
                Program[] programs = collectProgramsFromNode(node);
                if ((programs != null) && (programs.length > 0)) {
                  plugin.receivePrograms(programs, target);
                }
              }
            });
          } else if (targets.length >= 1) {
            JMenu subMenu = new JMenu(plugin.getInfo().getName());
            subMenu.setFont(MenuUtil.CONTEXT_MENU_PLAINFONT);

            Icon icon = plugin.getPluginIcon();

            subMenu.setIcon(icon != null ? icon : null);
            menu.add(subMenu);

            for (final ProgramReceiveTarget target : targets) {
              if (o == null || !o.equals(target)) {
                JMenuItem item = new JMenuItem(target.toString());
                item.setFont(MenuUtil.CONTEXT_MENU_PLAINFONT);
                subMenu.add(item);

                item.addActionListener(new ActionListener() {
                  public void actionPerformed(ActionEvent e) {
                    Program[] programs = collectProgramsFromNode(node);
                    if ((programs != null) && (programs.length > 0)) {
View Full Code Here

    if (menus != null && menus.length > 0)
    {
      final JMenuBar menuBar = new JMenuBar();
      for (int i = 0; i < menus.length; i++)
      {
        final JMenu menu = menus[i];
        menuBar.add(menu);
      }
      setJMenuBar(menuBar);
    }
    else
View Full Code Here

TOP

Related Classes of javax.swing.JMenu

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.