javax.swing.JMenuBar.<init>()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(12.2k)|赞(0)|评价(0)|浏览(114)

本文整理了Java中javax.swing.JMenuBar.<init>()方法的一些代码示例,展示了JMenuBar.<init>()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JMenuBar.<init>()方法的具体详情如下:
包路径:javax.swing.JMenuBar
类名称:JMenuBar
方法名:<init>

JMenuBar.<init>介绍

暂无

代码示例

代码示例来源:origin: kevin-wayne/algs4

private static JMenuBar createMenuBar() {
  JMenuBar menuBar = new JMenuBar();
  JMenu menu = new JMenu("File");
  menuBar.add(menu);
  JMenuItem menuItem1 = new JMenuItem(" Save...   ");
  menuItem1.addActionListener(std);
  menuItem1.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S,
              Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
  menu.add(menuItem1);
  return menuBar;
}

代码示例来源:origin: log4j/log4j

protected JMenuBar createMenuBar() {
 JMenuBar menuBar = new JMenuBar();
 menuBar.add(createFileMenu());
 menuBar.add(createEditMenu());
 menuBar.add(createLogLevelMenu());
 menuBar.add(createViewMenu());
 menuBar.add(createConfigureMenu());
 menuBar.add(createHelpMenu());
 return (menuBar);
}

代码示例来源:origin: skylot/jadx

exportAction.putValue(Action.ACCELERATOR_KEY, getKeyStroke(KeyEvent.VK_E, KeyEvent.CTRL_DOWN_MASK));
JMenu recentFiles = new JMenu(NLS.str("menu.recent_files"));
recentFiles.addMenuListener(new RecentFilesMenuListener(recentFiles));
    KeyEvent.CTRL_DOWN_MASK | KeyEvent.ALT_DOWN_MASK));
file.add(exitAction);
JMenu view = new JMenu(NLS.str("menu.view"));
view.setMnemonic(KeyEvent.VK_V);
view.add(flatPkgMenuItem);
help.add(aboutAction);
JMenuBar menuBar = new JMenuBar();
menuBar.add(file);
menuBar.add(view);
menuBar.add(nav);
menuBar.add(tools);
menuBar.add(help);

代码示例来源:origin: apache/tika

private void addMenuBar() {
  JMenuBar bar = new JMenuBar();
  JMenu file = new JMenu("File");
  file.setMnemonic(KeyEvent.VK_F);
  addMenuItem(file, "Open...", "openfile", KeyEvent.VK_O);
  addMenuItem(file, "Open URL...", "openurl", KeyEvent.VK_U);
  file.addSeparator();
  addMenuItem(file, "Exit", "exit", KeyEvent.VK_X);
  bar.add(file);
  JMenu view = new JMenu("View");
  view.setMnemonic(KeyEvent.VK_V);
  addMenuItem(view, "Metadata", "metadata", KeyEvent.VK_M);
  addMenuItem(view, "Formatted text", "html", KeyEvent.VK_F);
  addMenuItem(view, "Plain text", "text", KeyEvent.VK_P);
  addMenuItem(view, "Main content", "main", KeyEvent.VK_C);
  addMenuItem(view, "Structured text", "xhtml", KeyEvent.VK_S);
  addMenuItem(view, "Recursive JSON", "json", KeyEvent.VK_J);
  bar.add(view);
  bar.add(Box.createHorizontalGlue());
  JMenu help = new JMenu("Help");
  help.setMnemonic(KeyEvent.VK_H);
  addMenuItem(help, "About Tika", "about", KeyEvent.VK_A);
  bar.add(help);
  setJMenuBar(bar);
}

代码示例来源:origin: ron190/jsql-injection

JMenuBar menuBarVendor = new JMenuBar();
menuBarVendor.setOpaque(false);
menuBarVendor.setBorder(null);
menuBarVendor.add(comboMenuVendor);
  comboMenuVendor.add(itemRadioVendor);
  groupVendor.add(itemRadioVendor);

代码示例来源:origin: net.sf.tinylaf/tinylaf

private void createMenuBar() {
  JMenuBar menuBar = new JMenuBar();
  menuBar.add(createFileMenu());
  menuBar.add(createEditMenu());
  menuBar.add(createThemesMenu());
  menuBar.add(createDialogsMenu());
  menuBar.add(createMagnifierMenu());
  menuBar.add(createDisabledMenu());
  menuBar.add(createTestMenu());
  menuBar.add(createHelpMenu());
  menuBar.add(createRightToLeftMenu());
  menus[7] = menuBar;
  theFrame.setJMenuBar(menuBar);
}

代码示例来源:origin: kevin-wayne/algs4

private JMenuBar createMenuBar() {
  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);
  return menuBar;
}

代码示例来源:origin: camunda/camunda-bpm-platform

protected JMenuBar createMenuBar() {
 JMenuBar menuBar = new JMenuBar();
 menuBar.add(createFileMenu());
 menuBar.add(createEditMenu());
 menuBar.add(createLogLevelMenu());
 menuBar.add(createViewMenu());
 menuBar.add(createConfigureMenu());
 menuBar.add(createHelpMenu());
 return (menuBar);
}

代码示例来源:origin: libgdx/libgdx

private void initializeComponents () {
  JMenuBar menuBar = new JMenuBar();
  JMenu menu = new JMenu("File");
  menuBar.add(menu);
  JMenuItem menuItem = new JMenuItem("Open");
  menuItem.addActionListener(new ActionListener() {
  menu.add(menuItem);
  menuItem = new JMenuItem("Save");
  menuItem.addActionListener(new ActionListener() {
  menu.add(menuItem);
  setJMenuBar(menuBar);

代码示例来源:origin: apache/pdfbox

JMenuBar menuBar = new JMenuBar();
menuBar.add(createFileMenu());
menuBar.add(createEditMenu());
menuBar.add(viewMenu.getMenu());
setJMenuBar(menuBar);

代码示例来源:origin: libgdx/libgdx

private void initializeComponents () {
  JMenuBar menuBar = new JMenuBar();
  JMenu menu = new JMenu("File");
  menuBar.add(menu);
  JMenuItem menuItem = new JMenuItem("Open");
  menuItem.addActionListener(new ActionListener() {
  menu.add(menuItem);
  menuItem = new JMenuItem("Save");
  menuItem.addActionListener(new ActionListener() {
  menu.add(menuItem);
  setJMenuBar(menuBar);

代码示例来源:origin: libgdx/libgdx

private void initializeMenus () {
    JMenuBar menuBar = new JMenuBar();
    setJMenuBar(menuBar);
      JMenu fileMenu = new JMenu();
      menuBar.add(fileMenu);
      fileMenu.setText("File");
      fileMenu.setMnemonic(KeyEvent.VK_F);
        openMenuItem = new JMenuItem("Open Hiero settings file...");
        openMenuItem.setMnemonic(KeyEvent.VK_O);
        openMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, KeyEvent.CTRL_MASK));
        fileMenu.add(openMenuItem);
        saveMenuItem = new JMenuItem("Save Hiero settings file...");
        saveMenuItem.setMnemonic(KeyEvent.VK_S);
        saveMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, KeyEvent.CTRL_MASK));
        fileMenu.add(saveMenuItem);
        saveBMFontMenuItem = new JMenuItem("Save BMFont files (text)...");
        saveBMFontMenuItem.setMnemonic(KeyEvent.VK_B);
        saveBMFontMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_B, KeyEvent.CTRL_MASK));
        fileMenu.add(saveBMFontMenuItem);

代码示例来源:origin: libgdx/libgdx

private void initializeMenus () {
    JMenuBar menuBar = new JMenuBar();
    setJMenuBar(menuBar);
      JMenu fileMenu = new JMenu();
      menuBar.add(fileMenu);
      fileMenu.setText("File");
      fileMenu.setMnemonic(KeyEvent.VK_F);
        openMenuItem = new JMenuItem("Open Hiero settings file...");
        openMenuItem.setMnemonic(KeyEvent.VK_O);
        openMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, KeyEvent.CTRL_MASK));
        fileMenu.add(openMenuItem);
        saveMenuItem = new JMenuItem("Save Hiero settings file...");
        saveMenuItem.setMnemonic(KeyEvent.VK_S);
        saveMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, KeyEvent.CTRL_MASK));
        fileMenu.add(saveMenuItem);
        saveBMFontMenuItem = new JMenuItem("Save BMFont files (text)...");
        saveBMFontMenuItem.setMnemonic(KeyEvent.VK_B);
        saveBMFontMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_B, KeyEvent.CTRL_MASK));
        fileMenu.add(saveBMFontMenuItem);

代码示例来源:origin: kevin-wayne/algs4

/**
 * Displays 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);
    // use getMenuShortcutKeyMaskEx() in Java 10 (getMenuShortcutKeyMask() deprecated)           
    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);
    if (filename == null) frame.setTitle(width + "-by-" + height);
    else                  frame.setTitle(filename);
    frame.setResizable(false);
    frame.pack();
    frame.setVisible(true);
  }
  // draw
  frame.repaint();
}

代码示例来源:origin: kevin-wayne/algs4

/**
 * Displays 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);
    // use getMenuShortcutKeyMaskEx() in Java 10 (getMenuShortcutKeyMask() deprecated)
    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);
    if (filename == null) frame.setTitle(width + "-by-" + height);
    else                  frame.setTitle(filename);
    frame.setResizable(false);
    frame.pack();
    frame.setVisible(true);
  }
  // draw
  frame.repaint();
}

代码示例来源:origin: stanfordnlp/CoreNLP

private JMenuBar getMenu() {
 JMenuBar mbar = new JMenuBar();
 quit.addActionListener(this);
 file.add(loadFiles);
 file.add(loadTsurgeon);
 file.addSeparator();
 file.add(clearFileList);
 file.addSeparator();
 file.add(saveMatches);
 JMenu edit = new JMenu("Edit");
 copy = new JMenuItem("Copy");
 copy.setActionCommand((String)TransferHandler.getCopyAction().
 edit.add(copy);
 JMenu search = new JMenu("Search");
 searchMenuItem = new JMenuItem("Search");
 searchMenuItem.addActionListener(this);
 tools.add(tDiff);
 mbar.add(file);
 mbar.add(edit);
 mbar.add(search);
 mbar.add(tools);

代码示例来源:origin: stanfordnlp/CoreNLP

jMenuBar1 = new javax.swing.JMenuBar();
jMenu1 = new javax.swing.JMenu();
loadDataItem = new javax.swing.JMenuItem();
loadParserItem = new javax.swing.JMenuItem();
jSeparator1 = new javax.swing.JSeparator();
exitItem = new javax.swing.JMenuItem();
jMenu2 = new javax.swing.JMenu();
untokEngItem = new javax.swing.JCheckBoxMenuItem();
tokChineseItem = new javax.swing.JCheckBoxMenuItem();
loadDataItem.addActionListener(this::loadDataItemActionPerformed);
jMenu1.add(loadDataItem);
loadParserItem.setText("Load Parser");
loadParserItem.addActionListener(this::loadParserItemActionPerformed);
jMenu1.add(loadParserItem);
jMenu1.add(jSeparator1);
exitItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_X, java.awt.event.InputEvent.ALT_MASK));
exitItem.setMnemonic('x');
jMenu1.add(exitItem);
jMenuBar1.add(jMenu1);

代码示例来源:origin: log4j/log4j

final JMenuBar menuBar = new JMenuBar();
setJMenuBar(menuBar);
final JMenu menu = new JMenu("File");
menuBar.add(menu);
  final JMenuItem loadMenuItem = new JMenuItem("Load file...");
  menu.add(loadMenuItem);
  loadMenuItem.addActionListener(lxa);
} catch (NoClassDefFoundError e) {
final JMenuItem exitMenuItem = new JMenuItem("Exit");
menu.add(exitMenuItem);
exitMenuItem.addActionListener(ExitAction.INSTANCE);

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

private static void createMenu(){
  JMenuBar menuBar = new JMenuBar();
  frame.setJMenuBar(menuBar);
  JMenu menuTortureMethods = new JMenu("Canvas Torture Methods");
  menuBar.add(menuTortureMethods);
  final JMenuItem itemRemoveCanvas = new JMenuItem("Remove Canvas");
  menuTortureMethods.add(itemRemoveCanvas);
  itemRemoveCanvas.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
  final JMenuItem itemHideCanvas = new JMenuItem("Hide Canvas");
  menuTortureMethods.add(itemHideCanvas);
  itemHideCanvas.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
  final JMenuItem itemSwitchTab = new JMenuItem("Switch to tab #2");
  menuTortureMethods.add(itemSwitchTab);
  itemSwitchTab.addActionListener(new ActionListener(){
    public void actionPerformed(ActionEvent e){

代码示例来源:origin: stanfordnlp/CoreNLP

private JMenuBar addMenuBar() {
 JMenuBar menubar = new JMenuBar();
 JMenu fileMenu = new JMenu("File");
 menubar.add(fileMenu);
 JMenu editMenu = new JMenu("Edit");
 menubar.add(editMenu);
 JMenu classifierMenu = new JMenu("Classifier");
 menubar.add(classifierMenu);
 JMenuItem openFile = new JMenuItem("Open File");
 openFile.setMnemonic('O');
 openFile.setAccelerator(KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F, menuMask));
 openFile.addActionListener(actor);
 fileMenu.add(openFile);
 JMenuItem loadURL = new JMenuItem("Load URL");
 loadURL.setMnemonic('L');
 loadURL.setAccelerator(KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_U, menuMask));
 loadURL.addActionListener(actor);
 fileMenu.add(loadURL);
 fileMenu.add(new JSeparator());
 saveUntagged = new JMenuItem("Save Untagged File");
 saveUntagged.setMnemonic('S');
 saveUntagged.setAccelerator(KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, menuMask));

相关文章