Example #1
0
 public JMenuBar makeMenuBar() {
   JMenuBar bar = new JMenuBar();
   bar.add(makeFileMenu());
   bar.add(makeToolsMenu());
   bar.add(makeHelpMenu());
   return bar;
 }
Example #2
0
  private void initUI() {

    JMenuBar menubar = new JMenuBar();
    ImageIcon icon = new ImageIcon("exit.png");

    JMenu file = new JMenu("File");
    file.setMnemonic(KeyEvent.VK_F);

    JMenuItem eMenuItem = new JMenuItem("Exit", icon);
    eMenuItem.setMnemonic(KeyEvent.VK_E);
    eMenuItem.setToolTipText("Exit application");
    eMenuItem.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent event) {
            System.exit(0);
          }
        });

    file.add(eMenuItem);

    menubar.add(file);

    setJMenuBar(menubar);

    setTitle("Simple menu");
    setSize(300, 200);
    setLocationRelativeTo(null);
    setDefaultCloseOperation(EXIT_ON_CLOSE);
  }
 public JMenuBar getPanelMenuBar() {
   if (panelMenuBar == null) {
     JMenuItem menuItem;
     ICFLibAnyObj container = getSwingContainer();
     panelMenuBar = new JMenuBar();
     menuAdd = new JMenu("Add");
     actionAddMajorVersion = new ActionAddMajorVersion();
     if (container instanceof ICFInternetRealProjectObj) {
       menuItem = new JMenuItem(actionAddMajorVersion);
       menuAdd.add(menuItem);
     }
     actionAddMinorVersion = new ActionAddMinorVersion();
     if (container instanceof ICFInternetMajorVersionObj) {
       menuItem = new JMenuItem(actionAddMinorVersion);
       menuAdd.add(menuItem);
     }
     if (getSwingContainer() != null) {
       panelMenuBar.add(menuAdd);
     }
     menuSelected = new JMenu("Selected");
     menuSelected.setEnabled(false);
     actionViewSelected = new ViewSelectedActionVersion();
     menuItem = new JMenuItem(actionViewSelected);
     menuSelected.add(menuItem);
     actionEditSelected = new EditSelectedActionVersion();
     menuItem = new JMenuItem(actionEditSelected);
     menuSelected.add(menuItem);
     actionDeleteSelected = new DeleteSelectedActionVersion();
     menuItem = new JMenuItem(actionDeleteSelected);
     menuSelected.add(menuItem);
     panelMenuBar.add(menuSelected);
   }
   return (panelMenuBar);
 }
  private void initializeGUI() {

    JMenuBar menuBar = new JMenuBar();
    JMenu fileMenuGroup = new JMenu("File");
    JMenuItem fileExit = new JMenuItem("Exit");

    fileExit.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent arg0) {
            fileExit();
          }
        });

    setLayout(
        new FormLayout(
            "5px, 1px:grow, 1px:grow, 1px:grow, 1px:grow, 1px:grow, 5px",
            "25px, 1px:grow, 1px:grow, 5px"));

    fileMenuGroup.add(fileExit);
    menuBar.add(fileMenuGroup);
    add(menuBar, CC.xywh(2, 1, 5, 1));
    pack();

    Dimension size =
        new Dimension(
            VisualizationBase.WINDOW_SIZE.width + 17, VisualizationBase.WINDOW_SIZE.height + 94);
    setSize(size);
  }
    public CFrame() {
      super("Converter between Imperial and Metric.");

      setDefaultCloseOperation(EXIT_ON_CLOSE);

      JMenu menu = new JMenu("Application");
      menu.setBackground(white);
      menu.setMnemonic(KeyEvent.VK_A);

      // quit item
      JMenuItem item = new JMenuItem("Quit");
      item.setBackground(white);
      item.setMnemonic(KeyEvent.VK_Q);
      item.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              System.gc();
              System.exit(0);
            }
          });
      menu.add(item);

      JMenuBar menuBar = new JMenuBar();
      menuBar.setBackground(white);
      menuBar.add(menu);
      setJMenuBar(menuBar);

      setVisible(true);
    } // end of CFrame constructor
 private JMenuBar createMenu() {
   final JMenuBar bar = new JMenuBar();
   {
     final JMenu menu = bar.add(new JMenu("File"));
     menu.setMnemonic('F');
     menu.add(this.newMI("New", null, 'N', -1, this, "cmdNew"));
     menu.add(this.newMI("Open", null, 'O', KeyEvent.VK_O, this, "cmdOpen"));
     menu.addSeparator();
     menu.add(this.newMI("Export Png", null, 'P', KeyEvent.VK_E, this, "cmdExportPng"));
     menu.addSeparator();
     menu.add(this.newMI("Save", null, 'S', KeyEvent.VK_S, this, "cmdSave"));
     menu.add(this.newMI("Save As", null, 'A', -1, this, "cmdSaveAs"));
     menu.addSeparator();
     menu.add(this.newMI("Exit", null, 'x', -1, this, "cmdExit"));
   }
   {
     final JMenu menu = bar.add(new JMenu("View"));
     menu.setMnemonic('V');
     menu.add(this.newMI("Zoom", null, 'z', -1, this, "cmdZoom"));
   }
   {
     final JMenu menu = bar.add(new JMenu("Play"));
     menu.setMnemonic('P');
     menu.setEnabled(false);
     // menu.add(newMI('a', -1, bStart.getAction()));
     // menu.add(newMI('P', -1, bPause.getAction()));
     // menu.add(newMI('o', -1, bStop.getAction()));
   }
   {
     final JMenu menu = bar.add(new JMenu("Help"));
     menu.setMnemonic('H');
     menu.add(this.newMI("About", null, 'a', -1, this, "cmdAbout"));
   }
   return bar;
 }
  /*
   * This is the constructor for our ChoiceFrame
   */
  public ChoiceFrameExtras(String name) {
    // The keyword super simply sends name to the constructor of
    //  JFrame.
    super(name);

    // Construct the text
    sampleField = new JLabel(new String("Big Java"));

    // Add the text to the main panel
    getContentPane().add(sampleField, BorderLayout.CENTER);

    // Call the method below to add all the components and menu
    //  to the frame
    createControlPane();

    // Create and set the menu bar
    JMenuBar menuBar = new JMenuBar();
    setJMenuBar(menuBar);

    // Call the methods to add two menus (file and font) to the menu bar
    menuBar.add(createFileMenu());
    menuBar.add(createFontMenu());

    createColorDialog();

    // Call the method to re-draw the label
    setSampleFont();
  }
Example #8
0
  /** Create the terminal's menubar, all menus and items. */
  private JMenuBar makeMenuBar() {
    JMenuBar menubar = new JMenuBar();
    JMenu menu = new JMenu(Config.getString("terminal.options"));
    JMenuItem item;
    item = menu.add(new ClearAction());
    item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_K, SHORTCUT_MASK));
    item = menu.add(getCopyAction());
    item.setText(Config.getString("terminal.copy"));
    item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, SHORTCUT_MASK));
    item = menu.add(new SaveAction());
    item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, SHORTCUT_MASK));
    menu.add(new PrintAction());
    menu.add(new JSeparator());

    autoClear = new JCheckBoxMenuItem(new AutoClearAction());
    autoClear.setSelected(clearOnMethodCall);
    menu.add(autoClear);

    recordCalls = new JCheckBoxMenuItem(new RecordCallAction());
    recordCalls.setSelected(recordMethodCalls);
    menu.add(recordCalls);

    unlimitedBuffering = new JCheckBoxMenuItem(new BufferAction());
    unlimitedBuffering.setSelected(unlimitedBufferingCall);
    menu.add(unlimitedBuffering);

    menu.add(new JSeparator());
    item = menu.add(new CloseAction());
    item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_W, SHORTCUT_MASK));

    menubar.add(menu);
    return menubar;
  }
Example #9
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);
  }
Example #10
0
 public ImageViewerFrame() {
   setTitle("Frame");
   setSize(DEFAULT_WIDTH, DEFAULT_HIGHT);
   add(label);
   chooser.setCurrentDirectory(new File("."));
   JMenuBar menuBar = new JMenuBar();
   setJMenuBar(menuBar);
   JMenu menu = new JMenu("File");
   menuBar.add(menu);
   JMenuItem openItem = new JMenuItem("Open");
   menu.add(openItem);
   openItem.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent event) {
           int result = chooser.showOpenDialog(null);
           if (result == JFileChooser.APPROVE_OPTION) {
             String name = chooser.getSelectedFile().getPath();
             label.setIcon(new ImageIcon(name));
           }
         }
       });
   JMenuItem exitItem = new JMenuItem("Exit");
   menu.add(exitItem);
   exitItem.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent event) {
           System.exit(0);
         }
       });
 }
Example #11
0
  private void initComponents() {
    addWindowListener(
        new WindowAdapter() {
          @Override
          public void windowClosing(WindowEvent e) {
            setVisible(false);
          }
        });

    setSize(500, 500);

    saveTreeItem = new JMenuItem("Save");
    printItem = new JMenuItem("print");
    exitItem = new JMenuItem("exit");

    optionMenu = new JMenu("Option");
    optionMenu.addSeparator();
    optionMenu.add(saveTreeItem);
    optionMenu.addSeparator();
    optionMenu.add(printItem);
    optionMenu.addSeparator();
    optionMenu.add(exitItem);
    JMenuBar menuBar = new JMenuBar();
    menuBar.add(optionMenu);
    setJMenuBar(menuBar);

    saveTreeItem.addActionListener(this);
    printItem.addActionListener(this);
    exitItem.addActionListener(this);
  }
Example #12
0
  /** Display the picture in a window on the screen. */
  public void show() {

    // create the GUI for viewing the image if needed
    if (frame == null) {
      frame = new JFrame();

      JMenuBar menuBar = new JMenuBar();
      JMenu menu = new JMenu("File");
      menuBar.add(menu);
      JMenuItem menuItem1 = new JMenuItem(" Save...   ");
      menuItem1.addActionListener(this);
      menuItem1.setAccelerator(
          KeyStroke.getKeyStroke(
              KeyEvent.VK_S, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
      menu.add(menuItem1);
      frame.setJMenuBar(menuBar);

      frame.setContentPane(getJLabel());
      // f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
      frame.setTitle(filename);
      frame.setResizable(false);
      frame.pack();
      frame.setVisible(true);
    }

    // draw
    frame.repaint();
  }
Example #13
0
 /**
  * Gets the menubar.
  *
  * @return a menubar
  */
 private JMenuBar getMenubar() {
   if (toolmap.size() == 0) {
     try {
       toolmap.load(
           Toolbox.class
               .getClassLoader()
               .getResourceAsStream("org/openXpertya/print/pdf/tools/plugins/tools.txt"));
     } catch (IOException e) {
       e.printStackTrace();
     }
   }
   JMenuBar menubar = new JMenuBar();
   JMenu file = new JMenu(FILE);
   file.setMnemonic(KeyEvent.VK_F);
   JMenuItem close = new JMenuItem(CLOSE);
   close.setMnemonic(KeyEvent.VK_C);
   close.addActionListener(this);
   file.add(close);
   JMenu tools = new JMenu(TOOLS);
   file.setMnemonic(KeyEvent.VK_T);
   JMenuItem item;
   String name;
   for (Iterator i = toolmap.keySet().iterator(); i.hasNext(); ) {
     name = (String) i.next();
     item = new JMenuItem(name);
     item.addActionListener(this);
     tools.add(item);
   }
   menubar.add(file);
   menubar.add(tools);
   return menubar;
 }
Example #14
0
  // setUpMenu
  private void setUpMenu(JFrame window) {
    JMenuBar menubar = new JMenuBar();
    JMenu game = new JMenu("Game");
    JMenuItem newGame = new JMenuItem("NewGame");
    JMenuItem restart = new JMenuItem("Restart");
    JMenuItem forfeit = new JMenuItem("Forfeit");
    JMenuItem undo = new JMenuItem("Undo");
    JMenuItem score = new JMenuItem("Score");
    JMenuItem customerPiece = new JMenuItem("CustomerPiece");

    newGame.addActionListener(this);
    restart.addActionListener(this);
    forfeit.addActionListener(this);
    undo.addActionListener(this);
    score.addActionListener(this);
    customerPiece.addActionListener(this);
    game.add(newGame);
    game.add(restart);
    game.add(forfeit);
    game.add(undo);
    game.add(score);
    game.add(customerPiece);
    menubar.add(game);
    window.setJMenuBar(menubar);
  }
Example #15
0
  public void doIt() {
    mJFrame = new JFrame(mWindowName);
    mJFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    // Create the menu bar.
    mJMenuBarMain = new JMenuBar();
    mJMenuBarMain.setOpaque(true);
    mJMenuBarMain.setBackground(mMenuColor);
    mJMenuBarMain.setPreferredSize(new Dimension(X_WINDOW_SIZE, Y_MENU_SIZE));

    // Create main component
    mJMain = new JLabel();
    mJMain.setOpaque(true);
    mJMain.setBackground(mMainColor);
    mJMain.setPreferredSize(new Dimension(X_WINDOW_SIZE * 5, Y_WINDOW_SIZE * 150));

    JScrollPane scrollPane = new JScrollPane(mJMain);
    scrollPane.setPreferredSize(new Dimension(X_WINDOW_SIZE + 20, Y_WINDOW_SIZE + 20));

    // Set the menu bar and add the label to the content pane.
    mJFrame.setJMenuBar(mJMenuBarMain);
    mJFrame.getContentPane().add(scrollPane, BorderLayout.CENTER);
    mJFrame.setLocation(10, 10);

    // Display the window.
    mJFrame.pack();
    mJFrame.setVisible(true);
  }
 public JMenuBar getPanelMenuBar() {
   if (panelMenuBar == null) {
     JMenuItem menuItem;
     ICFLibAnyObj container = getSwingContainer();
     panelMenuBar = new JMenuBar();
     menuAdd = new JMenu("Add");
     actionAddTextCol = new ActionAddTextCol();
     if (container instanceof ICFDbTestTableObj) {
       menuItem = new JMenuItem(actionAddTextCol);
       menuAdd.add(menuItem);
     }
     actionAddTextType = new ActionAddTextType();
     if (container instanceof ICFDbTestSchemaDefObj) {
       menuItem = new JMenuItem(actionAddTextType);
       menuAdd.add(menuItem);
     }
     if (getSwingContainer() != null) {
       panelMenuBar.add(menuAdd);
     }
     menuSelected = new JMenu("Selected");
     menuSelected.setEnabled(false);
     actionViewSelected = new ViewSelectedActionTextDef();
     menuItem = new JMenuItem(actionViewSelected);
     menuSelected.add(menuItem);
     actionEditSelected = new EditSelectedActionTextDef();
     menuItem = new JMenuItem(actionEditSelected);
     menuSelected.add(menuItem);
     actionDeleteSelected = new DeleteSelectedActionTextDef();
     menuItem = new JMenuItem(actionDeleteSelected);
     menuSelected.add(menuItem);
     panelMenuBar.add(menuSelected);
   }
   return (panelMenuBar);
 }
Example #17
0
  public ImageViewerFrame() {
    logger.entering("ImageViewerFrame", "<init>");
    setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT);

    // set up menu bar
    JMenuBar menuBar = new JMenuBar();
    setJMenuBar(menuBar);
    JMenu menu = new JMenu("File");
    menuBar.add(menu);

    JMenuItem openItem = new JMenuItem("Open");
    menu.add(openItem);
    openItem.addActionListener(new FileOpenListener());
    JMenuItem exitItem = new JMenuItem("Exit");
    menu.add(exitItem);
    exitItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            logger.fine("Exiting.");
            System.exit(0);
          }
        });
    // use a label to display the images
    label = new JLabel();
    add(label);
    logger.exiting("ImageViewerFrame", "<init>");
  }
Example #18
0
    public DemoControls(Gradient demo) {
      super(demo.name);
      this.demo = demo;
      JMenuBar inMenuBar = new JMenuBar();
      add(inMenuBar);
      JMenuBar outMenuBar = new JMenuBar();
      add(outMenuBar);
      Font font = new Font("serif", Font.PLAIN, 10);

      imenu = (JMenu) inMenuBar.add(new JMenu("Inner Color"));
      imenu.setFont(font);
      imenu.setIcon(new ColoredSquare(demo.innerC));
      omenu = (JMenu) outMenuBar.add(new JMenu("Outer Color"));
      omenu.setFont(font);
      omenu.setIcon(new ColoredSquare(demo.outerC));
      for (int i = 0; i < colors.length; i++) {
        squares[i] = new ColoredSquare(colors[i]);
        innerMI[i] = imenu.add(new JMenuItem(colorName[i]));
        innerMI[i].setFont(font);
        innerMI[i].setIcon(squares[i]);
        innerMI[i].addActionListener(this);
        outerMI[i] = omenu.add(new JMenuItem(colorName[i]));
        outerMI[i].setFont(font);
        outerMI[i].setIcon(squares[i]);
        outerMI[i].addActionListener(this);
      }
    }
Example #19
0
  private JMenuBar createMenuBar() {
    JMenuBar menuBar = new JMenuBar();
    menuBar.add(createFileMenu());
    menuBar.add(createHelpMenu());

    return menuBar;
  }
Example #20
0
  public Bomberman() {
    /**
     * add(new Board()); setTitle("Bomberman"); setDefaultCloseOperation(EXIT_ON_CLOSE);
     * setSize(600, 550); setLocationRelativeTo(null); setVisible(true);
     */
    JFrame f = new JFrame("Bomberman");
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.setBounds(50, 50, 500, 545);

    JMenuBar mb = new JMenuBar();
    JMenu m1 = new JMenu("Datei");
    mb.add(m1);
    JMenuItem start = new JMenuItem("Neues Spiel");
    m1.add(start);
    start.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ev) {
            new Bomberman(); // Bugfix nötig
          }
        });
    JMenuItem end = new JMenuItem("Beenden");
    m1.add(end);

    end.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ev) {
            System.exit(1);
          }
        });

    f.setJMenuBar(mb);
    f.setLocationRelativeTo(null);
    f.getContentPane().add(new Board());
    f.setVisible(true);
  }
 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);
 }
Example #22
0
  protected void addMenuActions(JMenuBar mb) {
    JMenu fileMenu = new JMenu("File");

    addToMenu(actions.saveAction, fileMenu);
    addToMenu(actions.saveAsAction, fileMenu);
    fileMenu.addSeparator();
    addToMenu(actions.importAction, fileMenu);
    addToMenu(actions.exportAction, fileMenu);
    fileMenu.addSeparator();
    addToMenu(actions.exitAction, fileMenu);

    JMenu editMenu = new JMenu("Edit");
    addToMenu(actions.undoAction, editMenu);
    addToMenu(actions.copyAction, editMenu);
    addToMenu(actions.pasteAction, editMenu);
    editMenu.addSeparator();

    JMenu selectionMenu = new JMenu("Selection");

    for (Action a : actions.layoutActions) addToMenu(a, selectionMenu);
    editMenu.add(selectionMenu);

    JMenu viewMenu = new JMenu("View");
    JMenu zoomMenu = new JMenu("Zoom");
    viewMenu.add(zoomMenu);
    for (Action a : actions.zoomActions) addToMenu(a, zoomMenu);

    JMenu helpMenu = new JMenu("Help");

    mb.add(fileMenu);
    mb.add(editMenu);
    mb.add(viewMenu);
    mb.add(helpMenu);
  }
  /**
   * Method for setting up the menu bar and adding it to the main frame.
   *
   * @param frame the frame where to add the menu bar
   */
  private void addMenuBar(JFrame frame) {

    JMenuBar menuBar = new JMenuBar();
    frame.setJMenuBar(menuBar);

    // Menus
    file = new JMenu(lang.getText("ui.mainview.menu.file"));
    edit = new JMenu(lang.getText("ui.mainview.menu.edit"));
    help = new JMenu(lang.getText("ui.mainview.menu.help"));
    JMenuItem chooseLanguage = new JMenuItem(controller.getLanguageAction());

    // Sub menus
    JMenuItem about = new JMenuItem(controller.getAboutAction());
    JMenuItem addTodo = new JMenuItem(controller.getAddAction());
    JMenuItem editTodo = new JMenuItem(controller.getEditAction());
    JMenuItem deleteTodo = new JMenuItem(controller.getDeleteAction());
    JMenuItem setTodo = new JMenuItem(controller.getDoneAction());
    JMenuItem showGraph = new JMenuItem(controller.getShowGraphAction());

    // Set up menu bar
    menuBar.add(file);
    menuBar.add(edit);
    menuBar.add(help);
    file.add(chooseLanguage);
    file.add(showGraph);
    help.add(about);
    edit.add(addTodo);
    edit.add(editTodo);
    edit.add(deleteTodo);
    edit.add(setTodo);
  }
  /** Create menus to selct cross-section and spine */
  private void initMenus() {
    JMenuBar menuBar = new JMenuBar();

    JMenu crosssectionMenu = new JMenu("Cross-section");
    menuBar.add(crosssectionMenu);

    myCrossSectionSelection = new ButtonGroup();
    for (String s : myCrossSections.keySet()) {
      JMenuItem item = new JRadioButtonMenuItem(s);
      crosssectionMenu.add(item);
      myCrossSectionSelection.add(item);
      item.addItemListener(this);
    }
    myCrossSectionSelection.setSelected(
        myCrossSectionSelection.getElements().nextElement().getModel(), true);

    JMenu spineMenu = new JMenu("Spine");
    menuBar.add(spineMenu);

    mySpineSelection = new ButtonGroup();
    for (String s : mySpines.keySet()) {
      JMenuItem item = new JRadioButtonMenuItem(s);
      spineMenu.add(item);
      mySpineSelection.add(item);
      item.addItemListener(this);
    }
    mySpineSelection.setSelected(mySpineSelection.getElements().nextElement().getModel(), true);

    setJMenuBar(menuBar);
  }
  public TestSwingExample1() {
    super("ActionExample");

    setChannel(currentChannel); // enable/disable the Actions as appropriate

    channelLabel.setHorizontalAlignment(JLabel.CENTER);
    channelLabel.setFont(new Font("Serif", Font.PLAIN, 32));

    getContentPane().add(channelLabel, BorderLayout.NORTH);

    JPanel buttonPanel = new JPanel(new GridLayout(2, 2, 16, 6));
    buttonPanel.setBorder(BorderFactory.createEmptyBorder(6, 16, 16, 16));
    getContentPane().add(buttonPanel, BorderLayout.CENTER);

    buttonPanel.add(new JButton(upAction));
    buttonPanel.add(new JButton(gotoFavoriteAction));
    buttonPanel.add(new JButton(downAction));
    buttonPanel.add(new JButton(setFavoriteAction));

    JMenuBar mb = new JMenuBar();
    JMenu menu = new JMenu("Channel");
    menu.add(new JMenuItem(upAction));
    menu.add(new JMenuItem(downAction));
    menu.addSeparator();
    menu.add(new JMenuItem(gotoFavoriteAction));
    menu.add(new JMenuItem(setFavoriteAction));
    mb.add(menu);
    setJMenuBar(mb);
  }
Example #26
0
  public void setMenuBar(BeanTableFrame f) {
    final jmri.util.JmriJFrame finalF = f; // needed for anonymous ActionListener class
    JMenuBar menuBar = f.getJMenuBar();
    JMenu pathMenu = new JMenu("Paths");
    menuBar.add(pathMenu);
    JMenuItem item = new JMenuItem("Delete Paths...");
    pathMenu.add(item);
    item.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            deletePaths(finalF);
          }
        });

    JMenu speedMenu = new JMenu("Speeds");
    item = new JMenuItem("Defaults...");
    speedMenu.add(item);
    item.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            setDefaultSpeeds(finalF);
          }
        });
    menuBar.add(speedMenu);
  }
Example #27
0
 private JMenuBar createMenuBar(RecordLedgerTable table) {
   final JMenuBar bar = new JMenuBar();
   bar.add(createFileMenu());
   bar.add(createEditMenu());
   bar.add(createViewMenu(table));
   return bar;
 }
Example #28
0
  public static void main(String[] args) throws Exception {
    try {
      UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (Exception e) {
      e.printStackTrace();
    }

    UIManager.put("PopupMenuUI", "DropShadow.CustomPopupMenuUI");

    JFrame frame = new JFrame(DropShadowDemo.class.getSimpleName());
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JMenuBar mb = new JMenuBar();
    frame.setJMenuBar(mb);
    JMenu menu = new JMenu("File");
    mb.add(menu);
    menu.add(new JMenuItem("Open"));
    menu.add(new JMenuItem("Save"));
    menu.add(new JMenuItem("Close"));
    menu.add(new JMenuItem("Exit"));
    menu = new JMenu("Edit");
    mb.add(menu);
    menu.add(new JMenuItem("Cut"));
    menu.add(new JMenuItem("Copy"));
    menu.add(new JMenuItem("Paste"));
    frame.getContentPane().setLayout(new BorderLayout());
    frame.getContentPane().add("North", new JButton("Button"));
    frame.getContentPane().add("Center", new JLabel("a label"));
    frame.getContentPane().add("South", new JCheckBox("checkbox"));
    frame.pack();
    frame.setSize(200, 150);
    frame.setLocationRelativeTo(null);
    frame.show();
  }
  protected JMenuBar createMenuBar() {
    JMenuBar bar = new JMenuBar();
    JMenu homeMenu = new JMenu("Homing");
    bar.add(homeMenu);

    // adding the appropriate homing options for your endstop configuration
    for (AxisId axis : AxisId.values()) {
      Endstops endstops = machine.getDriver().getMachine().getEndstops(axis);
      if (endstops != null) {
        if (endstops.hasMin == true)
          homeMenu.add(
              makeHomeItem("Home " + axis.name() + " to minimum", EnumSet.of(axis), false));
        if (endstops.hasMax == true)
          homeMenu.add(makeHomeItem("Home " + axis.name() + " to maximum", EnumSet.of(axis), true));
      }
    }

    /*
    homeMenu.add(new JSeparator());
    homeMenu.add(makeHomeItem("Home XY+",EnumSet.of(Axis.X,Axis.Y),true));
    homeMenu.add(makeHomeItem("Home XY-",EnumSet.of(Axis.X,Axis.Y),false));
    homeMenu.add(makeHomeItem("Home all+",EnumSet.allOf(Axis.class),true));
    homeMenu.add(makeHomeItem("Home all-",EnumSet.allOf(Axis.class),false));
    */
    return bar;
  }
  public void createMenu() {
    // Creates file menu and items
    JMenu fileMenu = new JMenu(messages.getString("GUIRendWorkspace.file"));
    fileMenu.setMnemonic('F');
    JMenuItem newItem = new JMenuItem(messages.getString("GUIRendWorkspace.fileNew"));
    newItem.setMnemonic('N');
    newItem.addActionListener(new newComponent());
    JMenuItem saveItem = new JMenuItem(messages.getString("GUIRendWorkspace.fileSave"));
    saveItem.setMnemonic('S');
    JMenuItem loadItem = new JMenuItem(messages.getString("GUIRendWorkspace.fileLoad"));
    loadItem.setMnemonic('L');
    JMenuItem sourceItem = new JMenuItem(messages.getString("GUIRendWorkspace.fileSource"));
    sourceItem.setMnemonic('O');
    JMenuItem aboutItem = new JMenuItem(messages.getString("GUIRendWorkspace.fileAbout"));
    aboutItem.setMnemonic('A');
    fileMenu.add(newItem);
    fileMenu.add(sourceItem);
    fileMenu.add(aboutItem);

    JMenu windowMenu = new JMenu(messages.getString("GUIRendWorkspace.window"));
    windowMenu.setMnemonic('W');
    JMenuItem showWindowItem = new JMenuItem(messages.getString("GUIRendWorkspace.windowShow"));
    JMenuItem hideWindowItem = new JMenuItem(messages.getString("GUIRendWorkspace.windowHide"));
    windowMenu.add(showWindowItem);
    windowMenu.add(hideWindowItem);

    // Creates the menu bar
    JMenuBar menuBar = new JMenuBar();
    setJMenuBar(menuBar);
    menuBar.add(fileMenu);
  }