コード例 #1
0
ファイル: GridUI.java プロジェクト: nbald/thredds
  void addActionsToMenus(JMenu datasetMenu, JMenu configMenu, JMenu toolMenu) {
    // Info
    BAMutil.addActionToMenu(datasetMenu, showGridTableAction);
    BAMutil.addActionToMenu(datasetMenu, showDatasetInfoAction);
    BAMutil.addActionToMenu(datasetMenu, showNcMLAction);
    BAMutil.addActionToMenu(datasetMenu, showGridDatasetInfoAction);
    BAMutil.addActionToMenu(datasetMenu, showNetcdfDatasetAction);
    // BAMutil.addActionToMenu( datasetMenu, geotiffAction);
    // BAMutil.addActionToMenu( infoMenu, showNetcdfXMLAction);

    /// Configure
    JMenu toolbarMenu = new JMenu("Toolbars");
    toolbarMenu.setMnemonic('T');
    configMenu.add(toolbarMenu);
    BAMutil.addActionToMenu(toolbarMenu, navToolbarAction);
    BAMutil.addActionToMenu(toolbarMenu, moveToolbarAction);

    BAMutil.addActionToMenu(configMenu, chooseProjectionAction);
    BAMutil.addActionToMenu(configMenu, saveCurrentProjectionAction);

    /* BAMutil.addActionToMenu( configMenu, chooseColorScaleAction);
    BAMutil.addActionToMenu( configMenu, controller.dataProjectionAction);
    */

    //// tools menu
    JMenu displayMenu = new JMenu("Display control");
    displayMenu.setMnemonic('D');

    BAMutil.addActionToMenu(displayMenu, controller.showGridAction);
    BAMutil.addActionToMenu(displayMenu, controller.showContoursAction);
    BAMutil.addActionToMenu(displayMenu, controller.showContourLabelsAction);
    BAMutil.addActionToMenu(displayMenu, redrawAction);
    toolMenu.add(displayMenu);

    // Loop Control
    JMenu loopMenu = new JMenu("Loop control");
    loopMenu.setMnemonic('L');

    BAMutil.addActionToMenu(loopMenu, fieldLoopAction);
    BAMutil.addActionToMenu(loopMenu, levelLoopAction);
    BAMutil.addActionToMenu(loopMenu, timeLoopAction);
    toolMenu.add(loopMenu);

    // MinMax Control
    JMenu mmMenu = new JMenu("ColorScale min/max");
    mmMenu.setMnemonic('C');
    BAMutil.addActionToMenu(mmMenu, minmaxHorizAction);
    BAMutil.addActionToMenu(mmMenu, minmaxLogAction);
    BAMutil.addActionToMenu(mmMenu, minmaxHoldAction);
    toolMenu.add(mmMenu);

    // Zoom/Pan
    JMenu zoomMenu = new JMenu("Zoom/Pan");
    zoomMenu.setMnemonic('Z');
    panz.addActionsToMenu(zoomMenu); // items are added by NavigatedPanelToolbar
    toolMenu.add(zoomMenu);
  }
コード例 #2
0
ファイル: Plotter.java プロジェクト: susotajuraj/jdk8u-jdk
  @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;
  }
コード例 #3
0
  /** Creates the GUI. */
  public void majorLayout() {
    //
    // Setup Menu
    //
    JMenuBar menuBar = new JMenuBar();
    JMenu file = new JMenu(ResourceHandler.getMessage("menu.file"));
    file.setMnemonic(ResourceHandler.getAcceleratorKey("menu.file"));

    file.add(exitMenuItem = new JMenuItem(ResourceHandler.getMessage("menu.exit")));
    exitMenuItem.setMnemonic(ResourceHandler.getAcceleratorKey("menu.exit"));
    exitMenuItem.addActionListener(this);
    menuBar.add(file);

    JMenu edit = new JMenu(ResourceHandler.getMessage("menu.edit"));
    edit.setMnemonic(ResourceHandler.getAcceleratorKey("menu.edit"));

    edit.add(optionMenuItem = new JMenuItem(ResourceHandler.getMessage("menu.option")));
    optionMenuItem.setMnemonic(ResourceHandler.getAcceleratorKey("menu.option"));
    optionMenuItem.addActionListener(this);
    menuBar.add(edit);

    JMenu help = new JMenu(ResourceHandler.getMessage("menu.help"));
    help.setMnemonic(ResourceHandler.getAcceleratorKey("menu.help"));

    help.add(helpMenuItem = new JMenuItem(ResourceHandler.getMessage("menu.help")));
    helpMenuItem.setMnemonic(ResourceHandler.getAcceleratorKey("menu.help"));

    help.add(new JSeparator());
    help.add(aboutMenuItem = new JMenuItem(ResourceHandler.getMessage("menu.about")));
    aboutMenuItem.setMnemonic(ResourceHandler.getAcceleratorKey("menu.about"));
    helpMenuItem.addActionListener(this);
    aboutMenuItem.addActionListener(this);
    menuBar.add(help);

    setJMenuBar(menuBar);

    //
    // Setup main GUI
    //

    dirLabel = new JLabel(ResourceHandler.getMessage("converter_gui.lablel0"));
    dirTF = new JTextField();
    dirBttn = new JButton(ResourceHandler.getMessage("button.browse.dir"));
    dirBttn.setMnemonic(ResourceHandler.getAcceleratorKey("button.browse.dir"));

    matchingLabel = new JLabel(ResourceHandler.getMessage("converter_gui.lablel1"));
    matchingTF = new JTextField(ResourceHandler.getMessage("converter_gui.lablel2"));
    recursiveCheckBox = new JCheckBox(ResourceHandler.getMessage("converter_gui.lablel3"));
    recursiveCheckBox.setMnemonic(ResourceHandler.getAcceleratorKey("converter_gui.lablel3"));

    backupLabel = new JLabel(ResourceHandler.getMessage("converter_gui.lablel5"));
    backupTF = new JTextField();
    backupBttn = new JButton(ResourceHandler.getMessage("button.browse.backup"));
    backupBttn.setMnemonic(ResourceHandler.getAcceleratorKey("button.browse.backup"));

    templateLabel = new JLabel(ResourceHandler.getMessage("converter_gui.lablel7"));
    templateCh = new TemplateFileChoice();

    staticVersioningLabel = new JLabel(ResourceHandler.getMessage("static.versioning.label"));
    String version = System.getProperty("java.version");
    if (version.indexOf("-") > 0) {
      version = version.substring(0, version.indexOf("-"));
    }
    int dotIndex = version.indexOf(".");
    dotIndex = version.indexOf(".", dotIndex + 1);
    String familyVersion = version.substring(0, dotIndex);

    MessageFormat formatter =
        new MessageFormat(ResourceHandler.getMessage("static.versioning.radio.button"));
    staticVersioningRadioButton = new JRadioButton(formatter.format(new Object[] {version}));
    staticVersioningRadioButton.setMnemonic(
        ResourceHandler.getAcceleratorKey("static.versioning.radio.button"));

    formatter = new MessageFormat(ResourceHandler.getMessage("dynamic.versioning.radio.button"));
    dynamicVersioningRadioButton = new JRadioButton(formatter.format(new Object[] {familyVersion}));
    dynamicVersioningRadioButton.setMnemonic(
        ResourceHandler.getAcceleratorKey("dynamic.versioning.radio.button"));

    staticVersioningTextArea = new JTextArea(ResourceHandler.getMessage("static.versioning.text"));

    formatter = new MessageFormat(ResourceHandler.getMessage("dynamic.versioning.text"));
    dynamicVersioningTextArea = new JTextArea(formatter.format(new Object[] {familyVersion}));

    ButtonGroup versioningButtonGroup = new ButtonGroup();
    versioningButtonGroup.add(staticVersioningRadioButton);
    versioningButtonGroup.add(dynamicVersioningRadioButton);

    runBttn = new JButton(ResourceHandler.getMessage("button.convert"));
    runBttn.setMnemonic(ResourceHandler.getAcceleratorKey("button.convert"));

    recursiveCheckBox.setOpaque(false);
    staticVersioningRadioButton.setOpaque(false);
    dynamicVersioningRadioButton.setOpaque(false);

    staticVersioningTextArea.setEditable(false);
    staticVersioningTextArea.setLineWrap(true);
    staticVersioningTextArea.setWrapStyleWord(true);
    dynamicVersioningTextArea.setEditable(false);
    dynamicVersioningTextArea.setLineWrap(true);
    dynamicVersioningTextArea.setWrapStyleWord(true);

    staticVersioningPanel.setLayout(new BorderLayout());
    staticVersioningPanel.add(staticVersioningTextArea, "Center");
    staticVersioningPanel.setBorder(new LineBorder(Color.black));

    dynamicVersioningPanel.setLayout(new BorderLayout());
    dynamicVersioningPanel.add(dynamicVersioningTextArea, "Center");
    dynamicVersioningPanel.setBorder(new LineBorder(Color.black));

    if (converter.isStaticVersioning()) {
      staticVersioningRadioButton.setSelected(true);
    } else {
      dynamicVersioningRadioButton.setSelected(true);
    }

    addListeners();

    final int buf = 10, // Buffer (between components and form)
        sp = 10, // Space between components
        vsp = 5, // Vertical space
        indent = 20; // Indent between form (left edge) and component

    GridBagConstraints gbc = new GridBagConstraints();
    GridBagLayout gbl = new GridBagLayout();
    getContentPane().setLayout(gbl);

    //
    // Setup top panel
    //
    GridBagLayout topLayout = new GridBagLayout();
    JPanel topPanel = new JPanel();
    topPanel.setOpaque(false);
    topPanel.setLayout(topLayout);

    topLayout.setConstraints(
        dirLabel,
        new GridBagConstraints(
            0,
            0,
            1,
            1,
            0,
            0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(10, 0, 0, 0),
            0,
            0));
    topLayout.setConstraints(
        dirTF,
        new GridBagConstraints(
            1,
            0,
            1,
            1,
            1,
            0,
            GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL,
            new Insets(vsp, 2, 0, 0),
            0,
            0));
    topLayout.setConstraints(
        dirBttn,
        new GridBagConstraints(
            2,
            0,
            1,
            1,
            0,
            0,
            GridBagConstraints.CENTER,
            GridBagConstraints.NONE,
            new Insets(10, sp, 0, 0),
            0,
            0));
    topLayout.setConstraints(
        matchingLabel,
        new GridBagConstraints(
            0,
            1,
            1,
            1,
            0,
            0,
            GridBagConstraints.EAST,
            GridBagConstraints.NONE,
            new Insets(10, 0, 0, 0),
            0,
            0));
    topLayout.setConstraints(
        matchingTF,
        new GridBagConstraints(
            1,
            1,
            1,
            1,
            1,
            0,
            GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL,
            new Insets(vsp, 2, 0, 0),
            0,
            0));
    topLayout.setConstraints(
        recursiveCheckBox,
        new GridBagConstraints(
            2,
            1,
            GridBagConstraints.REMAINDER,
            1,
            1,
            0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(vsp, 10, 0, 0),
            0,
            0));
    topLayout.setConstraints(
        backupLabel,
        new GridBagConstraints(
            0,
            3,
            1,
            1,
            0,
            0,
            GridBagConstraints.EAST,
            GridBagConstraints.NONE,
            new Insets(10, 0, 0, 0),
            0,
            0));
    topLayout.setConstraints(
        backupTF,
        new GridBagConstraints(
            1,
            3,
            1,
            1,
            1,
            0,
            GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL,
            new Insets(vsp, 2, 0, 0),
            0,
            0));
    topLayout.setConstraints(
        backupBttn,
        new GridBagConstraints(
            2,
            3,
            1,
            1,
            0,
            0,
            GridBagConstraints.CENTER,
            GridBagConstraints.NONE,
            new Insets(10, sp, 0, 0),
            0,
            0));
    topLayout.setConstraints(
        templateLabel,
        new GridBagConstraints(
            0,
            4,
            1,
            1,
            0,
            0,
            GridBagConstraints.EAST,
            GridBagConstraints.NONE,
            new Insets(10, 0, 0, 0),
            0,
            0));
    topLayout.setConstraints(
        templateCh,
        new GridBagConstraints(
            1,
            4,
            1,
            1,
            0,
            0,
            GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL,
            new Insets(vsp, 2, 0, 0),
            0,
            0));
    topLayout.setConstraints(
        sep1,
        new GridBagConstraints(
            0,
            5,
            GridBagConstraints.REMAINDER,
            1,
            1,
            0,
            GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL,
            new Insets(10, 10, 10, 10),
            0,
            0));
    topLayout.setConstraints(
        staticVersioningLabel,
        new GridBagConstraints(
            0,
            6,
            1,
            1,
            0,
            0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(10, 0, 0, 0),
            0,
            0));
    topLayout.setConstraints(
        staticVersioningRadioButton,
        new GridBagConstraints(
            0,
            7,
            GridBagConstraints.REMAINDER,
            1,
            1,
            0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(vsp, 10, 0, 0),
            0,
            0));
    topLayout.setConstraints(
        staticVersioningPanel,
        new GridBagConstraints(
            0,
            8,
            GridBagConstraints.REMAINDER,
            1,
            0,
            0,
            GridBagConstraints.WEST,
            GridBagConstraints.BOTH,
            new Insets(vsp, 25, 10, 0),
            0,
            0));
    topLayout.setConstraints(
        dynamicVersioningRadioButton,
        new GridBagConstraints(
            0,
            9,
            GridBagConstraints.REMAINDER,
            1,
            1,
            0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(vsp, 10, 0, 0),
            0,
            0));
    topLayout.setConstraints(
        dynamicVersioningPanel,
        new GridBagConstraints(
            0,
            10,
            GridBagConstraints.REMAINDER,
            1,
            0,
            0,
            GridBagConstraints.WEST,
            GridBagConstraints.BOTH,
            new Insets(vsp, 25, 0, 0),
            0,
            0));
    topLayout.setConstraints(
        sep2,
        new GridBagConstraints(
            0,
            11,
            GridBagConstraints.REMAINDER,
            1,
            1,
            0,
            GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL,
            new Insets(10, 10, 0, 10),
            0,
            0));

    invisibleBttn = new JButton();
    invisibleBttn.setVisible(false);
    topLayout.setConstraints(
        invisibleBttn,
        new GridBagConstraints(
            2,
            6,
            1,
            1,
            0,
            0,
            GridBagConstraints.CENTER,
            GridBagConstraints.CENTER,
            new Insets(indent, sp, 0, 0),
            0,
            0));

    topPanel.add(dirLabel);
    topPanel.add(dirTF);
    topPanel.add(dirBttn);
    topPanel.add(matchingLabel);
    topPanel.add(matchingTF);
    topPanel.add(recursiveCheckBox);
    topPanel.add(backupLabel);
    topPanel.add(backupTF);
    topPanel.add(backupBttn);
    topPanel.add(templateLabel);
    topPanel.add(templateCh);
    topPanel.add(sep1);
    topPanel.add(staticVersioningLabel);
    topPanel.add(staticVersioningRadioButton);
    topPanel.add(staticVersioningPanel);
    topPanel.add(dynamicVersioningRadioButton);
    topPanel.add(dynamicVersioningPanel);
    topPanel.add(sep2);
    topPanel.add(invisibleBttn);

    //
    // Setup bottom panel
    //
    GridBagLayout buttomLayout = new GridBagLayout();
    JPanel buttomPanel = new JPanel();
    buttomPanel.setOpaque(false);
    buttomPanel.setLayout(buttomLayout);

    buttomLayout.setConstraints(
        runBttn,
        new GridBagConstraints(
            3,
            0,
            1,
            1,
            0,
            0,
            GridBagConstraints.CENTER,
            GridBagConstraints.NONE,
            new Insets(sp, 0, 0, 0),
            0,
            0));
    buttomPanel.add(runBttn);

    //
    // Setup main panel
    //
    GridBagLayout mainLayout = new GridBagLayout();
    JPanel mainPanel = new JPanel();

    mainPanel.setOpaque(false);
    mainPanel.setLayout(mainLayout);

    mainLayout.setConstraints(
        topPanel,
        new GridBagConstraints(
            0,
            0,
            1,
            1,
            1,
            0,
            GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL,
            new Insets(buf, buf, 0, buf),
            0,
            0));
    mainLayout.setConstraints(
        buttomPanel,
        new GridBagConstraints(
            0,
            1,
            1,
            1,
            1,
            1,
            GridBagConstraints.SOUTH,
            GridBagConstraints.HORIZONTAL,
            new Insets(0, buf, buf, buf),
            0,
            0));
    mainPanel.add(topPanel);
    mainPanel.add(buttomPanel);

    Border border = BorderFactory.createEtchedBorder();
    mainPanel.setBorder(border);

    GridBagLayout layout = new GridBagLayout();
    getContentPane().setLayout(layout);

    layout.setConstraints(
        mainPanel,
        new GridBagConstraints(
            0,
            0,
            1,
            1,
            1,
            1,
            GridBagConstraints.CENTER,
            GridBagConstraints.BOTH,
            new Insets(0, 0, 0, 0),
            0,
            0));

    getContentPane().add(mainPanel);

    pack();
    setResizable(false);
  }
コード例 #4
0
ファイル: GridUI.java プロジェクト: nbald/thredds
  private void makeUI(int defaultHeight) {

    datasetNameLabel = new JLabel();
    /* gridPP = new PrefPanel("GridView", (PreferencesExt) store.node("GridViewPrefs"));
    gridUrlIF = gridPP.addTextComboField("url", "Gridded Data URL", null, 10, false);
    gridPP.addButton( BAMutil.makeButtconFromAction( chooseLocalDatasetAction ));
    gridPP.finish(true, BorderLayout.EAST);
    gridPP.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        InvDatasetImpl ds = new InvDatasetImpl( gridUrlIF.getText(), thredds.catalog.DataType.GRID, ServiceType.NETCDF);
        setDataset( ds);
      }
    }); */

    // top tool panel
    toolPanel = new JPanel();
    toolPanel.setBorder(new EtchedBorder());
    toolPanel.setLayout(new MFlowLayout(FlowLayout.LEFT, 0, 0));

    // menus
    JMenu dataMenu = new JMenu("Dataset");
    dataMenu.setMnemonic('D');
    configMenu = new JMenu("Configure");
    configMenu.setMnemonic('C');
    JMenu toolMenu = new JMenu("Controls");
    toolMenu.setMnemonic('T');
    addActionsToMenus(dataMenu, configMenu, toolMenu);
    JMenuBar menuBar = new JMenuBar();
    menuBar.add(dataMenu);
    menuBar.add(configMenu);
    menuBar.add(toolMenu);
    toolPanel.add(menuBar);

    // field choosers
    fieldPanel = new JPanel();
    fieldPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
    toolPanel.add(fieldPanel);

    // stride
    toolPanel.add(controller.strideSpinner);

    // buttcons
    BAMutil.addActionToContainer(toolPanel, controller.drawHorizAction);
    BAMutil.addActionToContainer(toolPanel, controller.drawVertAction);
    mapBeanMenu = MapBean.makeMapSelectButton();
    toolPanel.add(mapBeanMenu.getParentComponent());

    // the Navigated panel and its toolbars
    panz.setLayout(new FlowLayout());
    navToolbar = panz.getNavToolBar();
    moveToolbar = panz.getMoveToolBar();
    if (((Boolean) navToolbarAction.getValue(BAMutil.STATE)).booleanValue())
      toolPanel.add(navToolbar);
    if (((Boolean) moveToolbarAction.getValue(BAMutil.STATE)).booleanValue())
      toolPanel.add(moveToolbar);

    BAMutil.addActionToContainer(toolPanel, panz.setReferenceAction);
    BAMutil.addActionToContainer(toolPanel, controller.dataProjectionAction);
    BAMutil.addActionToContainer(toolPanel, controller.showGridAction);
    BAMutil.addActionToContainer(toolPanel, controller.showContoursAction);
    BAMutil.addActionToContainer(toolPanel, controller.showContourLabelsAction);

    BAMutil.addActionToContainer(toolPanel, redrawAction);

    //  vertical split
    vertPanel = new VertPanel();
    splitDraw = new JSplitPane(JSplitPane.VERTICAL_SPLIT, panz, vertPanel);
    int divLoc = store.getInt("vertSplit", 2 * defaultHeight / 3);
    splitDraw.setDividerLocation(divLoc);
    drawingPanel = new JPanel(new BorderLayout()); // filled later

    // status panel
    JPanel statusPanel = new JPanel(new BorderLayout());
    statusPanel.setBorder(new EtchedBorder());
    positionLabel = new JLabel("position");
    positionLabel.setToolTipText("position at cursor");
    dataValueLabel = new JLabel("data value", SwingConstants.CENTER);
    dataValueLabel.setToolTipText("data value (double click on grid)");
    statusPanel.add(positionLabel, BorderLayout.WEST);
    statusPanel.add(dataValueLabel, BorderLayout.CENTER);
    panz.setPositionLabel(positionLabel);

    // colorscale panel
    colorScalePanel = new ColorScale.Panel(this, controller.getColorScale());
    csDataMinMax = new JComboBox(GridRenderer.MinMaxType.values());
    csDataMinMax.setToolTipText("ColorScale Min/Max setting");
    csDataMinMax.addActionListener(
        new AbstractAction() {
          public void actionPerformed(ActionEvent e) {
            controller.setDataMinMaxType((GridRenderer.MinMaxType) csDataMinMax.getSelectedItem());
          }
        });
    JPanel westPanel = new JPanel(new BorderLayout());
    westPanel.add(colorScalePanel, BorderLayout.CENTER);
    westPanel.add(csDataMinMax, BorderLayout.NORTH);

    // lay it out
    JPanel northPanel = new JPanel();
    // northPanel.setLayout( new BoxLayout(northPanel, BoxLayout.Y_AXIS));
    northPanel.setLayout(new BorderLayout());
    northPanel.add(datasetNameLabel, BorderLayout.NORTH);
    northPanel.add(toolPanel, BorderLayout.SOUTH);

    setLayout(new BorderLayout());
    add(northPanel, BorderLayout.NORTH);
    add(statusPanel, BorderLayout.SOUTH);
    add(westPanel, BorderLayout.WEST);
    add(drawingPanel, BorderLayout.CENTER);

    setDrawHorizAndVert(controller.drawHorizOn, controller.drawVertOn);
  }
コード例 #5
0
ファイル: BoggleGUI.java プロジェクト: nv23/Boggle
  private void setUpMenuBar() {
    // Set Up Menu Bar
    JMenuBar menu = new JMenuBar();

    // Game Menu
    JMenu gameMenu = new JMenu("Game");
    menu.add(gameMenu);

    JMenuItem newRandom = new JMenuItem("New Game");
    gameMenu.add(newRandom);
    newRandom.setAccelerator(
        KeyStroke.getKeyStroke(
            KeyEvent.VK_N, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    newRandom.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            newGame();
          }
        });

    gameMenu.addSeparator();

    ButtonGroup bg = new ButtonGroup();
    JRadioButtonMenuItem size4 = new JRadioButtonMenuItem("4x4 board");
    size4.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            myBoardSize = 4;
          }
        });
    size4.setSelected(true);
    bg.add(size4);
    gameMenu.add(size4);
    JRadioButtonMenuItem size5 = new JRadioButtonMenuItem("5x5 board");
    size5.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            myBoardSize = 5;
          }
        });
    bg.add(size5);
    gameMenu.add(size5);
    gameMenu.addSeparator();

    JMenuItem gameTime = new JMenuItem("Time (secs)");
    gameMenu.add(gameTime);
    gameTime.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            String secs = JOptionPane.showInputDialog(BoggleGUI.this, "time in seconds");
            try {
              int len = Integer.parseInt(secs);
              myGameLength = len;
              myProgress.setMaximum(myGameLength);
            } catch (NumberFormatException e1) {
              if (secs != null) {
                showError(secs + " not valid integer value");
              }
            }
          }
        });
    gameMenu.addSeparator();
    JMenuItem quitGame = new JMenuItem("Quit");
    gameMenu.add(quitGame);
    quitGame.setMnemonic('Q');
    quitGame.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            System.exit(0);
          }
        });

    // Help menu
    JMenu helpMenu = new JMenu("Help");
    menu.add(helpMenu);
    helpMenu.setMnemonic(KeyEvent.VK_H);

    JMenuItem aboutGame = new JMenuItem("About...");
    helpMenu.add(aboutGame);
    aboutGame.setMnemonic(KeyEvent.VK_A);
    aboutGame.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            JOptionPane.showMessageDialog(
                BoggleGUI.this,
                "Compsci Boggle, brought to you\n"
                    + "by educators and students\n"
                    + "including, of course, you.",
                "About Game",
                JOptionPane.PLAIN_MESSAGE);
          }
        });
    setJMenuBar(menu);
  }