/**
   * Aware-P Epanet application entry point
   *
   * @param args
   * @throws UnsupportedLookAndFeelException
   */
  public static void main(String[] args) throws UnsupportedLookAndFeelException {
    if (Utilities.isMac()) {
      System.setProperty("apple.laf.useScreenMenuBar", "true");
      System.setProperty("com.apple.mrj.application.apple.menu.about.name", "Aware-P Epanet");

      Application app = Application.getApplication();
      app.setDockIconImage(
          Toolkit.getDefaultToolkit().getImage(EpanetUI.class.getResource("/uiresources/ae.png")));

      JMenuBar menuBar = new JMenuBar();
      JMenu fileMenu = new JMenu("File");
      menuBar.add(fileMenu);

      openAction = new JMenuItem("Open");
      saveAction = new JMenuItem("Save");
      runAction = new JMenuItem("Run");

      fileMenu.add(openAction);
      fileMenu.add(saveAction);
      fileMenu.add(runAction);
      app.setDefaultMenuBar(menuBar);
    }
    UIManager.setLookAndFeel(new Plastic3DLookAndFeel());
    new EpanetUI();
  }
 public JMenuBar getPanelMenuBar() {
   if (panelMenuBar == null) {
     JMenuItem menuItem;
     ICFLibAnyObj container = getSwingContainer();
     panelMenuBar = new JMenuBar();
     menuAdd = new JMenu("Add");
     actionAddTopProject = new ActionAddTopProject();
     if (container instanceof ICFInternetDomainBaseObj) {
       menuItem = new JMenuItem(actionAddTopProject);
       menuAdd.add(menuItem);
     }
     if (getSwingContainer() != null) {
       panelMenuBar.add(menuAdd);
     }
     menuSelected = new JMenu("Selected");
     menuSelected.setEnabled(false);
     actionViewSelected = new ViewSelectedActionTopProject();
     menuItem = new JMenuItem(actionViewSelected);
     menuSelected.add(menuItem);
     actionEditSelected = new EditSelectedActionTopProject();
     menuItem = new JMenuItem(actionEditSelected);
     menuSelected.add(menuItem);
     actionDeleteSelected = new DeleteSelectedActionTopProject();
     menuItem = new JMenuItem(actionDeleteSelected);
     menuSelected.add(menuItem);
     panelMenuBar.add(menuSelected);
   }
   return (panelMenuBar);
 }
 /*
  * The following method creates the font menu
  * postcondition: returns the JMenu for the font menu.
  */
 public JMenu createFontMenu() {
   JMenu menu = new JMenu(new String("Font"));
   menu.add(createFontNameMenu());
   menu.add(createFontSizeMenu());
   menu.add(createFontStyleMenu());
   return menu;
 } // end createFontMenu method
示例#4
0
  /**
   * initialize the symbols menu
   *
   * @param m menu
   */
  public void initSymbolsMenu(JMenu m) {
    m.removeAll();
    for (int i = 0; i < glyphs.size(); i++) {
      final MetSymbol metSymbol = (MetSymbol) glyphs.get(i);
      JMenuItem mi = GuiUtils.makeMenuItem(metSymbol.getLabel(), this, "showProperties", metSymbol);
      mi.addMouseListener(
          new MouseAdapter() {
            public void mousePressed(MouseEvent e) {
              highlightedMetSymbol = null;
              StationModelCanvas.this.repaint();
            }

            public void mouseReleased(MouseEvent e) {
              highlightedMetSymbol = null;
              StationModelCanvas.this.repaint();
            }

            public void mouseEntered(MouseEvent e) {
              highlightedMetSymbol = metSymbol;
              StationModelCanvas.this.repaint();
            }

            public void mouseExited(MouseEvent e) {
              highlightedMetSymbol = null;
              StationModelCanvas.this.repaint();
            }
          });
      m.add(mi);
    }
  }
  /** Return a menu for DesktopWindow and add a special listener. */
  public static JMenu getCurrencyMenu(ActionListener listener) {
    JRadioButtonMenuItem menuItem;
    String defaultCurrency = Money.getCurrencyFor(Money.getDefaultCurrency());

    JMenu menu = new JMenu("Währung");
    ButtonGroup group = new ButtonGroup();

    JMenu europeanMenu = new JMenu("Europa");
    String europeanCurrencies[] = Money.getEuropeanCurrencyList();

    for (int i = 0; i < europeanCurrencies.length; i++) {
      menuItem = new RadioCurrencyMenuItem(europeanCurrencies[i]);
      menuItem.addActionListener(listener);
      europeanMenu.add(menuItem);

      group.add(menuItem);

      if (europeanCurrencies[i].startsWith(defaultCurrency)) {
        menuItem.setSelected(true);
      }

      if (i == 0) {
        europeanMenu.addSeparator();
      }
    }

    menu.add(europeanMenu);

    return menu;
  }
示例#6
0
  void initControls() {
    JMenuItem jmi;

    jmi = new JMenuItem("JImage Menu");
    jmi.setEnabled(false);
    popupMenu.add(jmi);

    jmi = new JMenuItem("Fit");
    jmi.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            fit = true;
            repaint();
          }
        });
    popupMenu.add(jmi);

    JMenu scaleMenu = new JMenu("Set Scale");
    popupMenu.add(scaleMenu);
    int scales[] = new int[] {25, 50, 100, 200, 400, 800};

    for (int i = 0; i < scales.length; i++) {
      jmi = new JMenuItem(scales[i] + " %");
      jmi.addActionListener(new ScaleAction(scales[i]));
      scaleMenu.add(jmi);
    }

    MyListener l = new MyListener();
    addMouseMotionListener(l);
    addMouseListener(l);
    addMouseWheelListener(l);
    addKeyListener(l);
  }
  protected JMenu buildFileMenu() {
    JMenu file = new JMenu("File");
    JMenuItem newWin = new JMenuItem("New");
    JMenuItem open = new JMenuItem("Open");
    JMenuItem quit = new JMenuItem("Quit");

    newWin.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            newDocument();
          }
        });

    open.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            openDocument();
          }
        });

    quit.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            quit();
          }
        });

    file.add(newWin);
    file.add(open);
    file.addSeparator();
    file.add(quit);
    return file;
  }
示例#8
0
文件: OpenFileDir.java 项目: NCIP/dwd
  /* constructor
   * Create a frame with JTextArea and a menubar
   * with a "File" dropdown menu.
   *
   * @param title: the title for the frame
   * @param whichFile: to indicate which load or save buuton
   */
  public OpenFileDir(String title, String whichFile) {
    super(title);
    fileNo = whichFile;
    Container content_pane = getContentPane();

    // Create a user interface.
    content_pane.setLayout(new BorderLayout());

    // Use the helper method makeMenuItem
    // for making the menu items and registering
    // their listener.
    JMenu m = new JMenu("File");

    // Modify task names to something relevant to
    // the particular program.
    m.add(fMenuLoad = makeMenuItem("Load"));
    m.add(fMenuSave = makeMenuItem("Save"));
    m.add(fMenuClose = makeMenuItem("Quit"));

    JMenuBar mb = new JMenuBar();
    mb.add(m);

    setJMenuBar(mb);
    setSize(400, 200);
  } /* end of the constructor */
示例#9
0
  public MainUI() {
    super("Neato Burrito");

    dLog.trace("In MainUI: " + MainUI.class.getCanonicalName());

    this.setBounds(0, 0, 500, 500);
    Container container = getContentPane();
    container.add(theDesktop);
    setJMenuBar(menubar);
    JMenu fileMenu = new JMenu("File");
    JMenuItem exitItem = new JMenuItem("Exit");
    exitItem.setMnemonic('X');
    exitItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            System.exit(0);
          }
        });
    fileMenu.add(exitItem);
    menubar.add(fileMenu);

    StatusUI statUI = new StatusUI();
    statUI.setVisible(true);
    theDesktop.add(statUI);

    setDefaultCloseOperation(EXIT_ON_CLOSE);
    pack();
    setVisible(true);
  }
示例#10
0
  /** Creates new form frmMenuTeste */
  public frmMenu() {
    // "pegue o conteúdo do painel" - adiciona o jDesktopPane ao JFrame (janela principal
    getContentPane().add(jdPane);

    // adiciona os menus à barra de menus (jmPrincipal)
    jmPrincipal.add(jmOperacao);
    jmPrincipal.add(jmFaturamento);
    jmPrincipal.add(jmBancoDeDados);

    // adiciona os itens aos respectivos menus
    jmOperacao.add(jmPedido);
    jmOperacao.add(jmReceberPedidosPendentes);
    jmOperacao.add(jmRealizarEntrega);
    jmFaturamento.add(jmEfetuarPagamento);
    jmBancoDeDados.add(jmCadCliente);
    jmBancoDeDados.add(jmCadProduto);

    // "ajusta" a barra de menu dentro da janela principal
    setJMenuBar(jmPrincipal);

    // adiciona actionlistener aos itens do menu para que os eventos sejam tratados
    jmPedido.addActionListener(this);
    jmReceberPedidosPendentes.addActionListener(this);
    jmRealizarEntrega.addActionListener(this);
    jmEfetuarPagamento.addActionListener(this);
    jmCadCliente.addActionListener(this);
    jmCadProduto.addActionListener(this);

    setSize(800, 600);
    setLocationRelativeTo(null);
    setResizable(false);
    setVisible(true);
    // initComponents();
  }
  private void addToRecent(String s) {

    for (int i = 0; i < iMaxRecent; i++) {
      if (s.equals(sRecent[i])) {
        return;
      }
    }

    if (sRecent[iRecent] != null) {
      mRecent.remove(iRecent);
    }

    sRecent[iRecent] = s;

    if (s.length() > 43) {
      s = s.substring(0, 40) + "...";
    }

    JMenuItem item = new JMenuItem(s);

    item.setActionCommand("#" + iRecent);
    item.addActionListener(this);
    mRecent.insert(item, iRecent);

    iRecent = (iRecent + 1) % iMaxRecent;
  }
  private void addMenuItems(JMenu f, String m[]) {

    Dimension d = Toolkit.getDefaultToolkit().getScreenSize();

    for (int i = 0; i < m.length; i++) {
      if (m[i].equals("--")) {
        f.addSeparator();
      } else if (m[i].equals("---")) {

        // (ulrivo): full size on screen with less than 640 width
        if (d.width >= 640) {
          f.addSeparator();
        } else {
          return;
        }
      } else {
        JMenuItem item = new JMenuItem(m[i].substring(1));
        char c = m[i].charAt(0);

        if (c != '-') {
          item.setMnemonic(c);
        }

        item.addActionListener(this);
        f.add(item);
      }
    }
  }
  public void adjustListMenuBar() {
    JMenuItem menuItem;
    Action act;
    String itemLabel;
    boolean enableState;
    boolean inEditState;
    boolean allowAdds;
    ICFInternetTopProjectObj selectedObj = getSwingFocusAsTopProject();
    CFJPanel.PanelMode mode = getPanelMode();
    if (mode == CFJPanel.PanelMode.Edit) {
      inEditState = true;
      if (getSwingContainer() != null) {
        allowAdds = true;
      } else {
        allowAdds = false;
      }
    } else {
      inEditState = false;
      allowAdds = false;
    }
    if (selectedObj == null) {
      enableState = false;
    } else {
      enableState = true;
    }

    if (actionViewSelected != null) {
      actionViewSelected.setEnabled(enableState);
    }
    if (actionEditSelected != null) {
      actionEditSelected.setEnabled(inEditState && enableState);
    }
    if (actionDeleteSelected != null) {
      actionDeleteSelected.setEnabled(inEditState && enableState);
    }
    if (actionAddTopProject != null) {
      actionAddTopProject.setEnabled(allowAdds);
    }

    if (menuAdd != null) {
      menuAdd.setEnabled(allowAdds);
    }
    if (menuSelected != null) {
      menuSelected.setEnabled(enableState);
      int itemCount = menuSelected.getItemCount();
      for (int itemIdx = 0; itemIdx < itemCount; itemIdx++) {
        menuItem = menuSelected.getItem(itemIdx);
        act = menuItem.getAction();
        if (act != null) {
          if (act == actionViewSelected) {
            menuItem.setEnabled(enableState);
          } else if (act == actionEditSelected) {
            menuItem.setEnabled(inEditState && enableState);
          } else if (act == actionDeleteSelected) {
            menuItem.setEnabled(inEditState && enableState);
          }
        }
      }
    }
  }
示例#14
0
 /**
  * Make the edit menu
  *
  * @param editMenu edit menu
  * @return edit menu
  */
 public JMenu makeEditMenu(JMenu editMenu) {
   editMenu.add(GuiUtils.makeDynamicMenu("Symbols", this, "initSymbolsMenu"));
   editMenu.add(
       GuiUtils.makeMenuItem("Set properties on selected", this, "setPropertiesOnSelected"));
   editMenu.addSeparator();
   return super.makeEditMenu(editMenu);
 }
示例#15
0
  private static void constructMenu() {
    final JFrame lFrame = (JFrame) viewModel.get("window.frame");

    final JMenuBar lMenuBar = new JMenuBar();
    lFrame.setJMenuBar(lMenuBar);
    viewModel.put("menu", lMenuBar);

    final JMenu lFileMenu = new JMenu("File");
    lFileMenu.setMnemonic(KeyEvent.VK_F);
    viewModel.put("menu.file", lFileMenu);
    lMenuBar.add(lFileMenu);

    final JMenuItem lExitItem = new JMenuItem((Action) viewModel.get("action.exit"));
    viewModel.put("menu.file.exit", lExitItem);
    lFileMenu.add(lExitItem);

    final JMenuItem lHelpMenu = new JMenu("Help");
    lHelpMenu.setMnemonic(KeyEvent.VK_H);
    viewModel.put("menu.help", lHelpMenu);
    lMenuBar.add(lHelpMenu);

    final JMenuItem lHelpTopicsItem = new JMenuItem((Action) viewModel.get("action.help"));
    viewModel.put("menu.help.topics", lHelpTopicsItem);
    lHelpMenu.add(lHelpTopicsItem);

    final JMenuItem lAboutItem = new JMenuItem((Action) viewModel.get("action.about"));
    viewModel.put("menu.help.about", lAboutItem);
    lHelpMenu.add(lAboutItem);
  }
 public JMenuBar getPanelMenuBar() {
   if (panelMenuBar == null) {
     JMenuItem menuItem;
     ICFLibAnyObj container = getSwingContainer();
     panelMenuBar = new JMenuBar();
     menuAdd = new JMenu("Add");
     actionAddSecGroupMember = new ActionAddSecGroupMember();
     if (container instanceof ICFSecuritySecGroupObj) {
       menuItem = new JMenuItem(actionAddSecGroupMember);
       menuAdd.add(menuItem);
     }
     if (getSwingContainer() != null) {
       panelMenuBar.add(menuAdd);
     }
     menuSelected = new JMenu("Selected");
     menuSelected.setEnabled(false);
     actionViewSelected = new ViewSelectedActionSecGroupMember();
     menuItem = new JMenuItem(actionViewSelected);
     menuSelected.add(menuItem);
     actionEditSelected = new EditSelectedActionSecGroupMember();
     menuItem = new JMenuItem(actionEditSelected);
     menuSelected.add(menuItem);
     actionDeleteSelected = new DeleteSelectedActionSecGroupMember();
     menuItem = new JMenuItem(actionDeleteSelected);
     menuSelected.add(menuItem);
     panelMenuBar.add(menuSelected);
   }
   return (panelMenuBar);
 }
示例#17
0
  private void enableAnalysis() {
    setAllEnabled(false);
    analysisMenu.setEnabled(true);

    // get info on state of analysis
    String scriptFile;
    Libgist.getAnalysisInfo(analysisInfo);

    // newAnalysisItem not enabled: can't create new profile, we just closed the index
    newAnalysisItem.setEnabled(false);
    openAnalysisItem.setEnabled(true);
    completeAnalysisItem.setEnabled(true);

    wkldStatsItem.setEnabled(analysisInfo.actualHasWkldStats);
    splitStatsItem.setEnabled(analysisInfo.actualHasSplitStats);
    penaltyStatsItem.setEnabled(analysisInfo.actualHasPenaltyStats);

    // general tree statistics are okay
    treeStatsMenu.setEnabled(true);
    utilItem.setEnabled(true);
    predSzItem.setEnabled(true);
    slotCntItem.setEnabled(true);

    // can always select another index or exit
    fileMenu.setEnabled(true);
    newItem.setEnabled(true);
    openItem.setEnabled(true);
    exitItem.setEnabled(true);
  }
示例#18
0
 private void createTreeStatsMenu() {
   treeStatsMenu = new JMenu("Tree Stats");
   menuBar.add(treeStatsMenu);
   utilItem = new JMenuItem("Utilization");
   treeStatsMenu.add(utilItem);
   utilItem.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent e) {
           Libgist.getWkldNodeStats(Libgist.NODEUTIL, 0, false);
           treeView.showStats(Libgist.nodeCnt, Libgist.displayStats, utilItem.getText());
         }
       });
   slotCntItem = new JMenuItem("Slot Count");
   treeStatsMenu.add(slotCntItem);
   slotCntItem.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent e) {
           Libgist.getWkldNodeStats(Libgist.SLOTCNT, 0, false);
           treeView.showStats(Libgist.nodeCnt, Libgist.displayStats, slotCntItem.getText());
         }
       });
   predSzItem = new JMenuItem("Predicate Size");
   treeStatsMenu.add(predSzItem);
   predSzItem.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent e) {
           Libgist.getWkldNodeStats(Libgist.PREDSIZE, 0, false);
           treeView.showStats(Libgist.nodeCnt, Libgist.displayStats, predSzItem.getText());
         }
       });
 }
示例#19
0
  @Override
  public JPopupMenu getComponentPopupMenu() {
    if (popupMenu == null) {
      popupMenu = new JPopupMenu(Messages.CHART_COLON);
      timeRangeMenu = new JMenu(Messages.PLOTTER_TIME_RANGE_MENU);
      timeRangeMenu.setMnemonic(Resources.getMnemonicInt(Messages.PLOTTER_TIME_RANGE_MENU));
      popupMenu.add(timeRangeMenu);
      menuRBs = new JRadioButtonMenuItem[rangeNames.length];
      ButtonGroup rbGroup = new ButtonGroup();
      for (int i = 0; i < rangeNames.length; i++) {
        menuRBs[i] = new JRadioButtonMenuItem(rangeNames[i]);
        rbGroup.add(menuRBs[i]);
        menuRBs[i].addActionListener(this);
        if (viewRange == rangeValues[i]) {
          menuRBs[i].setSelected(true);
        }
        timeRangeMenu.add(menuRBs[i]);
      }

      popupMenu.addSeparator();

      saveAsMI = new JMenuItem(Messages.PLOTTER_SAVE_AS_MENU_ITEM);
      saveAsMI.setMnemonic(Resources.getMnemonicInt(Messages.PLOTTER_SAVE_AS_MENU_ITEM));
      saveAsMI.addActionListener(this);
      popupMenu.add(saveAsMI);
    }
    return popupMenu;
  }
  protected JMenu makeFileMenu() {
    JMenu fileMenu = new JMenu("File");

    fileMenu.add(
        new AbstractAction("Open/Count") {
          public void actionPerformed(ActionEvent ev) {
            doRead();
          }
        });

    fileMenu.add(
        new AbstractAction("Compress") {
          public void actionPerformed(ActionEvent ev) {
            doSave();
          }
        });

    fileMenu.add(
        new AbstractAction("Uncompress") {
          public void actionPerformed(ActionEvent ev) {
            doDecode();
          }
        });

    fileMenu.add(
        new AbstractAction("Quit") {
          public void actionPerformed(ActionEvent ev) {
            System.exit(0);
          }
        });
    return fileMenu;
  }
  /** Create menus */
  private JMenuBar createMenus() {
    JMenuItem mi;
    // ***** create the menubar ****
    menuBar = new JMenuBar();

    // ***** create File menu
    fileMenu = (JMenu) menuBar.add(new JMenu("File"));
    fileMenu.setMnemonic('F');
    createMenuItem(fileMenu, "Print", 'P', "", new PrintAction(this));
    createMenuItem(fileMenu, "Close", 'C', "", new CloseAction(this));
    fileMenu.add(new JSeparator());
    createMenuItem(fileMenu, "Exit", 'E', "", new ExitAction());

    // ***** create laf switcher menu
    lafMenu = (JMenu) menuBar.add(new JMenu("Look & Feel"));
    lafMenu.setMnemonic('L');

    mi = createLafMenuItem(lafMenu, "Java Look & Feel", 'J', "", metal);
    mi.setSelected(true); // this is the default l&f
    metalMenuItem = mi;

    createLafMenuItem(lafMenu, "Macintosh Look & Feel", 'M', "", mac);

    createLafMenuItem(lafMenu, "Motif Look & Feel", 'F', "", motif);

    createLafMenuItem(lafMenu, "Windows Look & Feel", 'W', "", windows);

    // ***** create themes menu
    themesMenu = (JMenu) menuBar.add(new JMenu("Themes"));
    themesMenu.setMnemonic('T');

    mi = createThemesMenuItem(themesMenu, "Default", 'D', "", new DefaultMetalTheme());
    mi.setSelected(true); // This is the default theme

    createThemesMenuItem(themesMenu, "Aqua", 'A', "", new AquaTheme());

    createThemesMenuItem(themesMenu, "Charcoal", 'C', "", new CharcoalTheme());

    createThemesMenuItem(themesMenu, "High Contrast", 'H', "", new ContrastTheme());

    createThemesMenuItem(themesMenu, "Emerald", 'E', "", new EmeraldTheme());

    createThemesMenuItem(themesMenu, "Ruby", 'R', "", new RubyTheme());

    createThemesMenuItem(themesMenu, "Presentation", 'P', "", new DemoMetalTheme());

    createThemesMenuItem(themesMenu, "Sandstone", 'S', "", new KhakiMetalTheme());

    createThemesMenuItem(themesMenu, "Big High Contrast", 'I', "", new BigContrastMetalTheme());

    createThemesMenuItem(themesMenu, "Blue", 'B', "", new BlueTheme());

    createThemesMenuItem(themesMenu, "Cougaar", 'O', "", new CougaarTheme());

    createThemesMenuItem(
        themesMenu, "Cougaar Presentation", 'O', "", new CougaarPresentationTheme());

    return menuBar;
  }
示例#22
0
 private JMenu addMenu(
     JMenuBar menuBar, String label, int mnemonic, String accessibleDescription) {
   JMenu menu = new JMenu(label);
   menu.setMnemonic(mnemonic);
   menu.getAccessibleContext().setAccessibleDescription(accessibleDescription);
   menuBar.add(menu);
   return menu;
 }
 /*
  * The following method creates the submenu to choose a font style
  * postcondition: returns the JMenu for the font style submenu.
  */
 public JMenu createFontStyleMenu() {
   JMenu menu = new JMenu(new String("Style"));
   menu.add(createFontStyleItem(new String("Plain")));
   menu.add(createFontStyleItem(new String("Italic")));
   menu.add(createFontStyleItem(new String("Bold")));
   menu.add(createFontStyleItem(new String("Bold Italic")));
   return menu;
 } // end createFontStyleMenu method
示例#24
0
  /**
   * _more_
   *
   * @param symbols _more_
   * @param listener _more_
   * @param smm _more_
   * @return _more_
   */
  public static List makeStationModelMenuItems(
      List symbols, final ObjectListener listener, StationModelManager smm) {
    List items = new ArrayList();
    List subMenus = new ArrayList();
    Hashtable categories = new Hashtable();
    for (int i = 0; i < symbols.size(); i++) {
      StationModel sm = (StationModel) symbols.get(i);
      boolean isUsers = smm.isUsers(sm);
      String name = sm.getName();
      if (name.equals("")) continue;
      List toks = StringUtil.split(name, ">", true, true);
      if (toks.size() > 0) {
        name = (String) toks.get(toks.size() - 1);
      }
      JMenuItem item = new JMenuItem(GuiUtils.getLocalName(name, isUsers));
      item.addActionListener(
          new ObjectListener(sm) {
            public void actionPerformed(ActionEvent ae) {
              listener.setObject(this.theObject);
              listener.actionPerformed(ae);
            }
          });

      toks.remove(toks.size() - 1);
      if (toks.size() == 0) {
        items.add(item);
        continue;
      }
      JMenu categoryMenu = null;
      String catSoFar = "";
      String menuCategory = "";
      for (int catIdx = 0; catIdx < toks.size(); catIdx++) {
        String subCat = (String) toks.get(catIdx);
        catSoFar = catSoFar + "/" + subCat;
        JMenu m = (JMenu) categories.get(catSoFar);
        if (m == null) {
          m = new JMenu(subCat);
          menuCategory = catSoFar;
          categories.put(catSoFar, m);
          if (categoryMenu != null) {
            categoryMenu.add(m, 0);
          } else {
            subMenus.add(m);
          }
        }
        categoryMenu = m;
      }
      if (categoryMenu == null) {
        categoryMenu = new JMenu("");
        categories.put(toks.toString(), categoryMenu);
        subMenus.add(categoryMenu);
        menuCategory = toks.toString();
      }
      categoryMenu.add(item);
    }
    items.addAll(subMenus);
    return items;
  }
示例#25
0
  public void start() {
    menu.setMnemonic('f');
    submenu.setMnemonic('m');
    menu.add(submenu);
    submenu.add(item);
    bar.add(menu);
    frame.setJMenuBar(bar);
    frame.pack();

    item.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            Sysout.println(e.toString());
            synchronized (activated) {
              activated.set(true);
              activated.notifyAll();
            }
          }
        });

    frame.setVisible(true);
    Util.waitForIdle(robot);

    boolean isMacOSX = (OSInfo.getOSType() == OSInfo.OSType.MACOSX);
    if (isMacOSX) {
      robot.keyPress(KeyEvent.VK_CONTROL);
      robot.delay(20);
    }
    robot.keyPress(KeyEvent.VK_ALT);
    robot.delay(20);
    robot.keyPress(KeyEvent.VK_F);
    robot.delay(20);
    robot.keyRelease(KeyEvent.VK_F);
    robot.delay(20);
    robot.keyRelease(KeyEvent.VK_ALT);
    if (isMacOSX) {
      robot.keyRelease(KeyEvent.VK_CONTROL);
      robot.delay(20);
    }
    Util.waitForIdle(robot);

    robot.keyPress(KeyEvent.VK_M);
    robot.delay(20);
    robot.keyRelease(KeyEvent.VK_M);
    Util.waitForIdle(robot);

    robot.keyPress(KeyEvent.VK_SPACE);
    robot.delay(20);
    robot.keyRelease(KeyEvent.VK_SPACE);
    Util.waitForIdle(robot);

    if (!Util.waitForCondition(activated, 2000)) {
      throw new TestFailedException("a submenu wasn't activated by mnemonic key press");
    }

    Sysout.println("Test passed.");
  }
示例#26
0
 public static JMenu createLookAndFeelMenu() {
   JMenu menu = new JMenu("LookAndFeel");
   ButtonGroup lookAndFeelRadioGroup = new ButtonGroup();
   for (UIManager.LookAndFeelInfo lafInfo : UIManager.getInstalledLookAndFeels()) {
     menu.add(
         createLookAndFeelItem(lafInfo.getName(), lafInfo.getClassName(), lookAndFeelRadioGroup));
   }
   return menu;
 }
示例#27
0
  /**
   * Define the main About menu.
   *
   * @param al the action listener to associate to the menu.
   * @return the menu.
   */
  public JMenu defineAboutMenu(ActionListener al) {
    JMenu about = new JMenu(Globals.messages.getString("About"));
    JMenuItem aboutMenu = new JMenuItem(Globals.messages.getString("About_menu"));
    about.add(aboutMenu);

    aboutMenu.addActionListener(al);

    return about;
  }
示例#28
0
  public ConnectionForm() {
    setContentPane(contentPane);
    setModal(true);
    getRootPane().setDefaultButton(buttonOK);

    JMenuBar menuBar = new JMenuBar();
    menuBar.setVisible(true);

    JMenu menu = new JMenu("Menu");
    menu.setVisible(true);

    JMenuItem statementItem = new JMenuItem("SQL Insert");
    statementItem.setVisible(true);
    statementItem.addActionListener(new SQLImportActionListener());
    statementItem.setEnabled(false);

    JMenuItem importItem = new JMenuItem("Files Import");
    importItem.setEnabled(false);
    importItem.setVisible(true);

    menu.add(statementItem);
    menu.add(importItem);
    menuBar.add(menu);
    setJMenuBar(menuBar);

    buttonOK.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            JFileChooser fileChooser = new JFileChooser();
            fileChooser.setCurrentDirectory(new File(System.getProperty("user.home")));
            int result = fileChooser.showOpenDialog(getParent());
          }
        });

    dbField.addMouseListener(new DBFileMouseListener(getParent()));
    filesField.addMouseListener(new SQLFilesMouseListener(getParent()));

    // call onCancel() when cross is clicked
    setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
    addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            onCancel();
          }
        });

    // call onCancel() on ESCAPE
    contentPane.registerKeyboardAction(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            onCancel();
          }
        },
        KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0),
        JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
  }
  public void go() {
    frame = new JFrame("Quiz Card Player");
    JPanel mainPanel = new JPanel();
    Font bigFont = new Font("sanserif", Font.BOLD, 24);

    display = new JTextArea(10, 20);
    display.setFont(bigFont);
    display.setLineWrap(true);
    display.setEditable(false);

    JScrollPane qScroller = new JScrollPane(display);
    qScroller.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    qScroller.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);

    nextButton = new JButton("Show Questions");
    nextButton.addActionListener(new NextCardListener());

    mainPanel.add(qScroller);
    mainPanel.add(nextButton);

    JMenuBar menuBar = new JMenuBar();
    JMenu fileMenu = new JMenu("File");
    JMenuItem loadMenuItem = new JMenuItem("Load Card Set");
    loadMenuItem.addActionListener(new OpenMenuListener());
    fileMenu.add(loadMenuItem);
    menuBar.add(fileMenu);

    frame.setJMenuBar(menuBar);
    frame.getContentPane().add(BorderLayout.CENTER, mainPanel);
    frame.setSize(640, 500);
    frame.setVisible(true);
  }
  public void go() {
    // build gui

    frame = new JFrame("Quiz Card Buider");
    JPanel mainPanel = new JPanel();
    Font bigFont = new Font("sanserif", Font.BOLD, 24);
    question = new JTextArea(6, 20);
    question.setLineWrap(true);
    question.setWrapStyleWord(true);
    question.setFont(bigFont);

    JScrollPane qScroller = new JScrollPane(question);
    qScroller.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
    qScroller.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);

    answer = new JTextArea(6, 20);
    answer.setLineWrap(true);
    answer.setWrapStyleWord(true);
    answer.setFont(bigFont);

    JScrollPane aScroller = new JScrollPane(question);
    aScroller.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
    aScroller.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);

    JButton nextButton = new JButton("Next Card");

    cardList = new ArrayList<QuizCard>();

    JLabel qLabel = new JLabel("Question");
    JLabel aLabel = new JLabel("Answer");

    mainPanel.add(qLabel);
    mainPanel.add(qScroller);
    mainPanel.add(aLabel);
    mainPanel.add(aScroller);
    mainPanel.add(nextButton);

    nextButton.addActionListener(new NextCardListener());

    JMenuBar menuBar = new JMenuBar();

    JMenu fileMenu = new JMenu("File");

    JMenuItem newMenuItem = new JMenuItem("New");
    JMenuItem saveMenuItem = new JMenuItem("Save");
    newMenuItem.addActionListener(new NewMenuListener());
    saveMenuItem.addActionListener(new SaveMenuListener());

    fileMenu.add(newMenuItem);
    fileMenu.add(saveMenuItem);
    menuBar.add(fileMenu);
    frame.setJMenuBar(menuBar);
    frame.getContentPane().add(BorderLayout.CENTER, mainPanel);
    frame.setSize(500, 600);
    frame.setVisible(true);
    // frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

  }