public void changeDictionary(String strLanguage) {
    // Change dictionary
    MonitorDictionary.setCurrentLanguage(strLanguage);
    DefaultDictionary.setCurrentLanguage(strLanguage);
    ErrorDictionary.setCurrentLanguage(strLanguage);

    // Update UI
    updateLanguage();
    WindowManager.updateLanguage();
    int iIndex = mvtLanguage.indexOf(strLanguage);
    if (iIndex >= 0) {
      JRadioButtonMenuItem mnu = (JRadioButtonMenuItem) mvtLanguageItem.elementAt(iIndex);
      mnu.setSelected(true);
    }

    // Store config
    Hashtable prt = null;
    try {
      prt = Global.loadHashtable(Global.FILE_CONFIG);
    } catch (Exception e) {
      prt = new Hashtable();
    }
    prt.put("Language", strLanguage);
    try {
      Global.storeHashtable(prt, Global.FILE_CONFIG);
    } catch (Exception e) {
    }
  }
  /** Called when a choice was made in the animation type combo box. */
  public void animationCombo_actionPerformed() {
    int selectedIndex = animationCombo.getSelectedIndex();
    switch (selectedIndex) {
      case HackController.DISPLAY_CHANGES:
        if (!partAnimMenuItem.isSelected()) partAnimMenuItem.setSelected(true);
        break;

      case HackController.ANIMATION:
        if (!fullAnimMenuItem.isSelected()) fullAnimMenuItem.setSelected(true);
        break;

      case HackController.NO_DISPLAY_CHANGES:
        if (!noAnimMenuItem.isSelected()) noAnimMenuItem.setSelected(true);
        break;
    }

    notifyControllerListeners(ControllerEvent.ANIMATION_MODE_CHANGE, new Integer(selectedIndex));
  }
  /** Called when a choice was made in the numeric format combo box. */
  public void formatCombo_actionPerformed() {
    int selectedIndex = formatCombo.getSelectedIndex();
    switch (selectedIndex) {
      case HackController.DECIMAL_FORMAT:
        if (!decMenuItem.isSelected()) decMenuItem.setSelected(true);
        break;

      case HackController.HEXA_FORMAT:
        if (!hexaMenuItem.isSelected()) hexaMenuItem.setSelected(true);
        break;

      case HackController.BINARY_FORMAT:
        if (!binMenuItem.isSelected()) binMenuItem.setSelected(true);
        break;
    }

    notifyControllerListeners(ControllerEvent.NUMERIC_FORMAT_CHANGE, selectedIndex);
  }
  /** Called when a choice was made in the additional display combo box. */
  public void additionalDisplayCombo_actionPerformed() {
    int selectedIndex = additionalDisplayCombo.getSelectedIndex();
    switch (selectedIndex) {
      case HackController.SCRIPT_ADDITIONAL_DISPLAY:
        if (!scriptMenuItem.isSelected()) scriptMenuItem.setSelected(true);
        break;

      case HackController.OUTPUT_ADDITIONAL_DISPLAY:
        if (!outputMenuItem.isSelected()) outputMenuItem.setSelected(true);
        break;

      case HackController.COMPARISON_ADDITIONAL_DISPLAY:
        if (!compareMenuItem.isSelected()) compareMenuItem.setSelected(true);
        break;

      case HackController.NO_ADDITIONAL_DISPLAY:
        if (!noAdditionalDisplayMenuItem.isSelected())
          noAdditionalDisplayMenuItem.setSelected(true);
        break;
    }

    notifyControllerListeners(
        ControllerEvent.ADDITIONAL_DISPLAY_CHANGE, new Integer(selectedIndex));
  }
Esempio n. 5
0
 /**
  * This method initializes jRadioButtonMenuItem
  *
  * @return JRadioButtonMenuItem
  */
 private JRadioButtonMenuItem getJRadioButtonMenuItem() {
   if (jRadioButtonMenuItem == null) {
     jRadioButtonMenuItem = new JRadioButtonMenuItem();
     jRadioButtonMenuItem.setText("Default");
     jRadioButtonMenuItem.setSelected(true);
     jRadioButtonMenuItem.setAccelerator(
         javax.swing.KeyStroke.getKeyStroke(
             java.awt.event.KeyEvent.VK_D, java.awt.Event.ALT_MASK, false));
     jRadioButtonMenuItem.setMnemonic(java.awt.event.KeyEvent.VK_D);
     jRadioButtonMenuItem.addActionListener(
         new java.awt.event.ActionListener() {
           public void actionPerformed(java.awt.event.ActionEvent e) {
             changeLnF(UIManager.getCrossPlatformLookAndFeelClassName());
           }
         });
   }
   return jRadioButtonMenuItem;
 }
  /** Adds the menu items to the menuber. */
  protected void arrangeMenu() {

    // Build the first menu.
    fileMenu = new JMenu("File");
    fileMenu.setMnemonic(KeyEvent.VK_F);
    menuBar.add(fileMenu);

    viewMenu = new JMenu("View");
    viewMenu.setMnemonic(KeyEvent.VK_V);
    menuBar.add(viewMenu);

    runMenu = new JMenu("Run");
    runMenu.setMnemonic(KeyEvent.VK_R);
    menuBar.add(runMenu);

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

    programMenuItem = new JMenuItem("Load Program", KeyEvent.VK_O);
    programMenuItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            programMenuItem_actionPerformed();
          }
        });
    fileMenu.add(programMenuItem);

    scriptMenuItem = new JMenuItem("Load Script", KeyEvent.VK_P);
    scriptMenuItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            scriptMenuItem_actionPerformed();
          }
        });
    fileMenu.add(scriptMenuItem);
    fileMenu.addSeparator();

    exitMenuItem = new JMenuItem("Exit", KeyEvent.VK_X);
    exitMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, InputEvent.ALT_MASK));
    exitMenuItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            exitMenuItem_actionPerformed();
          }
        });
    fileMenu.add(exitMenuItem);

    viewMenu.addSeparator();

    ButtonGroup animationRadioButtons = new ButtonGroup();

    animationSubMenu = new JMenu("Animate");
    animationSubMenu.setMnemonic(KeyEvent.VK_A);
    viewMenu.add(animationSubMenu);

    partAnimMenuItem = new JRadioButtonMenuItem("Program flow");
    partAnimMenuItem.setMnemonic(KeyEvent.VK_P);
    partAnimMenuItem.setSelected(true);
    partAnimMenuItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            partAnimMenuItem_actionPerformed();
          }
        });
    animationRadioButtons.add(partAnimMenuItem);
    animationSubMenu.add(partAnimMenuItem);

    fullAnimMenuItem = new JRadioButtonMenuItem("Program & data flow");
    fullAnimMenuItem.setMnemonic(KeyEvent.VK_D);
    fullAnimMenuItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            fullAnimMenuItem_actionPerformed();
          }
        });
    animationRadioButtons.add(fullAnimMenuItem);
    animationSubMenu.add(fullAnimMenuItem);

    noAnimMenuItem = new JRadioButtonMenuItem("No Animation");
    noAnimMenuItem.setMnemonic(KeyEvent.VK_N);
    noAnimMenuItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            noAnimMenuItem_actionPerformed();
          }
        });
    animationRadioButtons.add(noAnimMenuItem);
    animationSubMenu.add(noAnimMenuItem);

    ButtonGroup additionalDisplayRadioButtons = new ButtonGroup();

    additionalDisplaySubMenu = new JMenu("View");
    additionalDisplaySubMenu.setMnemonic(KeyEvent.VK_V);
    viewMenu.add(additionalDisplaySubMenu);

    scriptDisplayMenuItem = new JRadioButtonMenuItem("Script");
    scriptDisplayMenuItem.setMnemonic(KeyEvent.VK_S);
    scriptDisplayMenuItem.setSelected(true);
    scriptDisplayMenuItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            scriptDisplayMenuItem_actionPerformed();
          }
        });
    additionalDisplayRadioButtons.add(scriptDisplayMenuItem);
    additionalDisplaySubMenu.add(scriptDisplayMenuItem);

    outputMenuItem = new JRadioButtonMenuItem("Output");
    outputMenuItem.setMnemonic(KeyEvent.VK_O);
    outputMenuItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            outputMenuItem_actionPerformed();
          }
        });
    additionalDisplayRadioButtons.add(outputMenuItem);
    additionalDisplaySubMenu.add(outputMenuItem);

    compareMenuItem = new JRadioButtonMenuItem("Compare");
    compareMenuItem.setMnemonic(KeyEvent.VK_C);
    compareMenuItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            compareMenuItem_actionPerformed();
          }
        });
    additionalDisplayRadioButtons.add(compareMenuItem);
    additionalDisplaySubMenu.add(compareMenuItem);

    noAdditionalDisplayMenuItem = new JRadioButtonMenuItem("Screen");
    noAdditionalDisplayMenuItem.setMnemonic(KeyEvent.VK_N);
    noAdditionalDisplayMenuItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            noAdditionalDisplayMenuItem_actionPerformed();
          }
        });
    additionalDisplayRadioButtons.add(noAdditionalDisplayMenuItem);
    additionalDisplaySubMenu.add(noAdditionalDisplayMenuItem);

    ButtonGroup formatRadioButtons = new ButtonGroup();

    numericFormatSubMenu = new JMenu("Format");
    numericFormatSubMenu.setMnemonic(KeyEvent.VK_F);
    viewMenu.add(numericFormatSubMenu);

    decMenuItem = new JRadioButtonMenuItem("Decimal");
    decMenuItem.setMnemonic(KeyEvent.VK_D);
    decMenuItem.setSelected(true);
    decMenuItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            decMenuItem_actionPerformed();
          }
        });
    formatRadioButtons.add(decMenuItem);
    numericFormatSubMenu.add(decMenuItem);

    hexaMenuItem = new JRadioButtonMenuItem("Hexadecimal");
    hexaMenuItem.setMnemonic(KeyEvent.VK_H);
    hexaMenuItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            hexaMenuItem_actionPerformed();
          }
        });
    formatRadioButtons.add(hexaMenuItem);
    numericFormatSubMenu.add(hexaMenuItem);

    binMenuItem = new JRadioButtonMenuItem("Binary");
    binMenuItem.setMnemonic(KeyEvent.VK_B);
    binMenuItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            binMenuItem_actionPerformed();
          }
        });
    formatRadioButtons.add(binMenuItem);
    numericFormatSubMenu.add(binMenuItem);

    viewMenu.addSeparator();

    singleStepMenuItem = new JMenuItem("Single Step", KeyEvent.VK_S);
    singleStepMenuItem.setAccelerator(KeyStroke.getKeyStroke("F11"));
    singleStepMenuItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            singleStepMenuItem_actionPerformed();
          }
        });
    runMenu.add(singleStepMenuItem);

    ffwdMenuItem = new JMenuItem("Run", KeyEvent.VK_F);
    ffwdMenuItem.setAccelerator(KeyStroke.getKeyStroke("F5"));
    ffwdMenuItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            ffwdMenuItem_actionPerformed();
          }
        });
    runMenu.add(ffwdMenuItem);

    stopMenuItem = new JMenuItem("Stop", KeyEvent.VK_T);
    stopMenuItem.setAccelerator(KeyStroke.getKeyStroke("shift F5"));
    stopMenuItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            stopMenuItem_actionPerformed();
          }
        });
    runMenu.add(stopMenuItem);

    rewindMenuItem = new JMenuItem("Reset", KeyEvent.VK_R);
    rewindMenuItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            rewindMenuItem_actionPerformed();
          }
        });
    runMenu.add(rewindMenuItem);

    runMenu.addSeparator();

    breakpointsMenuItem = new JMenuItem("Breakpoints", KeyEvent.VK_B);
    breakpointsMenuItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            breakpointsMenuItem_actionPerformed();
          }
        });
    runMenu.add(breakpointsMenuItem);

    profilerMenuItem = new JMenuItem("Profiler", KeyEvent.VK_I);
    profilerMenuItem.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            showProfiler();
          }
        });
    profilerMenuItem.setEnabled(false);
    runMenu.add(profilerMenuItem);

    usageMenuItem = new JMenuItem("Usage", KeyEvent.VK_U);
    usageMenuItem.setAccelerator(KeyStroke.getKeyStroke("F1"));
    usageMenuItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            usageMenuItem_actionPerformed();
          }
        });
    helpMenu.add(usageMenuItem);

    aboutMenuItem = new JMenuItem("About ...", KeyEvent.VK_A);
    aboutMenuItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            aboutMenuItem_actionPerformed();
          }
        });
    helpMenu.add(aboutMenuItem);
  }
Esempio n. 7
0
  /** Creates new instance. */
  public ODGDrawingPanel() {
    ResourceBundleUtil labels = ResourceBundleUtil.getBundle("org.jhotdraw.draw.Labels");
    initComponents();
    undoManager = new UndoRedoManager();
    editor = new DefaultDrawingEditor();
    editor.add(view);

    addCreationButtonsTo(creationToolbar, editor);
    ButtonFactory.addAttributesButtonsTo(attributesToolbar, editor);

    JPopupButton pb = new JPopupButton();
    pb.setItemFont(UIManager.getFont("MenuItem.font"));
    labels.configureToolBarButton(pb, "actions");
    pb.add(new DuplicateAction());
    pb.addSeparator();
    pb.add(new GroupAction(editor));
    pb.add(new UngroupAction(editor));
    pb.addSeparator();
    pb.add(new BringToFrontAction(editor));
    pb.add(new SendToBackAction(editor));
    pb.addSeparator();
    pb.add(new CutAction());
    pb.add(new CopyAction());
    pb.add(new PasteAction());
    pb.add(new SelectAllAction());
    pb.add(new SelectSameAction(editor));
    pb.addSeparator();
    pb.add(undoManager.getUndoAction());
    pb.add(undoManager.getRedoAction());
    // FIXME - We need a toggle grid action
    // pb.addSeparator();
    // pb.add(new ToggleGridAction(editor));

    JMenu m = new JMenu(labels.getString("view.zoomFactor.text"));
    JRadioButtonMenuItem rbmi;
    ButtonGroup group = new ButtonGroup();
    m.add(rbmi = new JRadioButtonMenuItem(new ZoomAction(editor, 0.1, null)));
    group.add(rbmi);
    m.add(rbmi = new JRadioButtonMenuItem(new ZoomAction(editor, 0.25, null)));
    group.add(rbmi);
    m.add(rbmi = new JRadioButtonMenuItem(new ZoomAction(editor, 0.5, null)));
    group.add(rbmi);
    m.add(rbmi = new JRadioButtonMenuItem(new ZoomAction(editor, 0.75, null)));
    group.add(rbmi);
    m.add(rbmi = new JRadioButtonMenuItem(new ZoomAction(editor, 1.0, null)));
    rbmi.setSelected(true);
    group.add(rbmi);
    m.add(rbmi = new JRadioButtonMenuItem(new ZoomAction(editor, 1.25, null)));
    group.add(rbmi);
    m.add(rbmi = new JRadioButtonMenuItem(new ZoomAction(editor, 1.5, null)));
    group.add(rbmi);
    m.add(rbmi = new JRadioButtonMenuItem(new ZoomAction(editor, 2, null)));
    group.add(rbmi);
    m.add(rbmi = new JRadioButtonMenuItem(new ZoomAction(editor, 3, null)));
    group.add(rbmi);
    m.add(rbmi = new JRadioButtonMenuItem(new ZoomAction(editor, 4, null)));
    group.add(rbmi);
    pb.add(m);
    pb.setFocusable(false);
    creationToolbar.addSeparator();
    creationToolbar.add(pb);

    DefaultDrawing drawing = new DefaultDrawing();
    view.setDrawing(drawing);
    drawing.addUndoableEditListener(undoManager);
  }
Esempio n. 8
0
  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);
  }