当前位置: 首页>>代码示例>>Java>>正文


Java JFrame.setJMenuBar方法代码示例

本文整理汇总了Java中javax.swing.JFrame.setJMenuBar方法的典型用法代码示例。如果您正苦于以下问题:Java JFrame.setJMenuBar方法的具体用法?Java JFrame.setJMenuBar怎么用?Java JFrame.setJMenuBar使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.JFrame的用法示例。


在下文中一共展示了JFrame.setJMenuBar方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createAndShowGUI

import javax.swing.JFrame; //导入方法依赖的package包/类
private static void createAndShowGUI(TestItem testItem) {

        frame = new JFrame();
        frame.setSize(300, 300);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        JMenuBar menuBar = new JMenuBar();
        menu = new JMenu("Menu");
        JMenuItem menuItem = testItem.getMenuItem();
        testItem.setProperties(menuItem);
        menu.add(menuItem);
        menuBar.add(menu);

        frame.setJMenuBar(menuBar);
        frame.setVisible(true);
    }
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:17,代码来源:CloseOnMouseClickPropertyTest.java

示例2: showUI

import javax.swing.JFrame; //导入方法依赖的package包/类
private static void showUI() {
    sFrame = new JFrame();
    sFrame.add(new JLabel("Some dummy content"));

    JMenuBar menuBar = new JMenuBar();

    sMenu = new JMenu("Menu");
    JMenuItem item = new JMenuItem("Item");
    sMenu.add(item);

    sMenuItem = new WeakReference<>(item);

    menuBar.add(sMenu);

    sFrame.setJMenuBar(menuBar);

    sFrame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
    sFrame.pack();
    sFrame.setVisible(true);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:21,代码来源:ScreenMenuMemoryLeakTest.java

示例3: createAndShowGUI

import javax.swing.JFrame; //导入方法依赖的package包/类
/**
 * Create the GUI and show it. For thread safety, this method should be
 * invoked from the event-dispatching thread.
 */
private static void createAndShowGUI() {
    // Create and set up the window.
    JFrame frame = new JFrame("PopupMenuDemo");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    // Create/set menu bar and content pane.
    PopupMenuDemoX demo = new PopupMenuDemoX();
    frame.setJMenuBar(demo.createMenuBar());
    frame.setContentPane(demo.createContentPane());

    // Create and set up the popup menu.
    demo.createPopupMenu();

    // Display the window.
    frame.setSize(450, 260);
    frame.setVisible(true);
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:22,代码来源:PopupMenuDemoX.java

示例4: setup

import javax.swing.JFrame; //导入方法依赖的package包/类
private static void setup(JFrame frame) {
    JMenuBar menuBar = new JMenuBar();
    frame.setJMenuBar(menuBar);

    // First Menu, F - Mnemonic
    JMenu firstMenu = new JMenu("First Menu");
    firstMenu.setMnemonic(KeyEvent.VK_F);
    firstMenu.add(new JMenuItem("One", KeyEvent.VK_O));
    firstMenu.add(new JMenuItem("Two", KeyEvent.VK_T));
    menuBar.add(firstMenu);

    // Second Menu, S - Mnemonic
    JMenu secondMenu = new JMenu("Second Menu");
    secondMenu.setMnemonic(KeyEvent.VK_S);
    secondMenu.add(new JMenuItem("A Menu Item", KeyEvent.VK_A));
    menuBar.add(secondMenu);

    frame.setSize(350, 250);
    frame.setVisible(true);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:21,代码来源:bug6921687.java

示例5: Gui

import javax.swing.JFrame; //导入方法依赖的package包/类
public Gui() throws ClassNotFoundException, InstantiationException, IllegalAccessException, UnsupportedLookAndFeelException {
	UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
	frame = new JFrame("ElectroLight Penetration Testing");
	menuBar = new JMenuBar();
	frame.setJMenuBar(menuBar);
	
	JMenu mnCounterhack = new JMenu("Counter-hack");
	menuBar.add(mnCounterhack);
	
	JMenuItem mntmArpScan = new JMenuItem("ARP Scan");
	mnCounterhack.add(mntmArpScan);
	frame.setSize(300, 200);
	
	JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
	frame.getContentPane().add(tabbedPane, BorderLayout.CENTER);
	
	// Always keep the 2 following lines at the end.
	//frame.pack();
	frame.setVisible(true);
}
 
开发者ID:Electro-Light,项目名称:ElectroLight-Penetration-Testing,代码行数:21,代码来源:Gui.java

示例6: createGUI

import javax.swing.JFrame; //导入方法依赖的package包/类
private static JFrame createGUI() {
    JMenuBar menuBar = new JMenuBar();
    JMenu menu = new JMenu("Some menu");
    menuBar.add(menu);

    for (int i = 0; i < 10; i++) {
        menu.add(new JMenuItem("Some menu #" + i));
    }

    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setMinimumSize(new Dimension(200, 200));
    frame.setJMenuBar(menuBar);
    return frame;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:16,代码来源:bug8071705.java

示例7: InputGUI

import javax.swing.JFrame; //导入方法依赖的package包/类
public InputGUI(CommandLineOptions ops) {
    Thread splash = new Thread(new SplashScreen());
    splash.start();

    System.setErr(errs);
    pt = new Thread();

    guiFrame = new JFrame();
    guiFrame.setTitle("TuLiPA " + InputGUI.VERSION);
    guiFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    guiFrame.setJMenuBar(getMenuBar());
    guiFrame.setContentPane(getContainer());
    guiFrame.pack();
    guiFrame.setResizable(false);
    guiFrame.setLocationRelativeTo(null);

    shellFrame = new JFrame();
    shellFrame.setTitle("TuLiPA shell");
    shellFrame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
    shellFrame.setContentPane(auxshell);
    shellFrame.setSize(new Dimension(400, 300));
    shellFrame.setResizable(true);
    shellFrame.setLocationRelativeTo(guiFrame);

    this.setOps(ops);
    localops = null;

    guiFrame.setVisible(true);

}
 
开发者ID:spetitjean,项目名称:TuLiPA-frames,代码行数:31,代码来源:InputGUI.java

示例8: createAndShowGUI

import javax.swing.JFrame; //导入方法依赖的package包/类
/**
 * Create the GUI and show it. For thread safety, this method should be
 * invoked from the event-dispatching thread.
 */
private static void createAndShowGUI() {
    // Create and set up the window.
    JFrame frame = new JFrame("MenuDemo");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    // Create and set up the content pane.
    MenuDemo demo = new MenuDemo();
    frame.setJMenuBar(demo.createMenuBar());
    frame.setContentPane(demo.createContentPane());

    // Display the window.
    frame.setSize(450, 260);
    frame.setVisible(true);
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:19,代码来源:MenuDemo.java

示例9: createAndShowGUI

import javax.swing.JFrame; //导入方法依赖的package包/类
/**
 * Create the GUI and show it. For thread safety, this method should be
 * invoked from the event-dispatching thread.
 */
private static void createAndShowGUI() {
    // Create and set up the window.
    JFrame frame = new JFrame("MenuSelectionManagerDemo");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    // Create and set up the content pane.
    MenuSelectionManagerDemo demo = new MenuSelectionManagerDemo();
    frame.setJMenuBar(demo.createMenuBar());
    frame.setContentPane(demo.createContentPane());

    // Display the window.
    frame.setSize(450, 260);
    frame.setVisible(true);
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:19,代码来源:MenuSelectionManagerDemo.java

示例10: createAndShowGUI

import javax.swing.JFrame; //导入方法依赖的package包/类
/**
 * Create the GUI and show it. For thread safety, this method should be
 * invoked from the event-dispatching thread.
 */
private static void createAndShowGUI() {
    // Create and set up the window.
    JFrame frame = new JFrame("MenuLookDemo");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    // Create and set up the content pane.
    MenuLookDemo demo = new MenuLookDemo();
    frame.setJMenuBar(demo.createMenuBar());
    frame.setContentPane(demo.createContentPane());

    // Display the window.
    frame.setSize(450, 260);
    frame.setVisible(true);
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:19,代码来源:MenuLookDemo.java

示例11: toggleVisible

import javax.swing.JFrame; //导入方法依赖的package包/类
public void toggleVisible() {
  if (controlPanel.getTopLevelAncestor() == null) {
    if (GlobalOptions.getInstance().isUseSingleWindow()) {
      splitter = new ComponentSplitter().splitRight(GameModule.getGameModule().getControlPanel(), controlPanel, false);
      splitter.revalidate();
      final Runnable runnable = new Runnable() {
        public void run() {
          splitter.showComponent();
        }
      };
      SwingUtilities.invokeLater(runnable);
    }
    else {
      final JFrame frame = new JFrame(Resources.getString("Chat.server"));  //$NON-NLS-1$
      frame.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);
      frame.add(controlPanel);
      frame.setJMenuBar(MenuManager.getInstance().getMenuBarFor(frame));

      final String key = "BoundsOfClientWindow";  //$NON-NLS-1$
      final PositionOption pos = new VisibilityOption(key, frame);
      GameModule.getGameModule().getPrefs().addOption(pos);
      frame.setVisible(true);
    }
  }
  else if (splitter != null) {
    splitter.toggleVisibility();
  }
  else {
    controlPanel.getTopLevelAncestor().setVisible(!controlPanel.getTopLevelAncestor().isVisible());
  }
}
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:32,代码来源:ChatServerControls.java

示例12: init

import javax.swing.JFrame; //导入方法依赖的package包/类
/**
* 
* @Title: init 
* @Description: Component Initialization 
* @param
* @return void 
* @throws
 */
private static void init()
{
    MenuBarView mbv = new MenuBarView();
    JFrame frame = new JFrame(FormatConst.FORMAT_VERSION);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setJMenuBar(mbv.getJMenuBar());
    frame.getContentPane().add(FormatView.getView());
    frame.pack();
    frame.setVisible(true);
    frame.setIconImage(FormatUtil.getImage(FormatConst.LOGO));
    FormatUtil.setLocation(frame);
}
 
开发者ID:wisdomtool,项目名称:formatter,代码行数:21,代码来源:FormatMain.java

示例13: run

import javax.swing.JFrame; //导入方法依赖的package包/类
@Override
public void run() {
    final JMenuBar menubar = new JMenuBar();
    menubar.add(new JMenu(""));
    menubar.add(new JMenu(""));
    final JFrame frame = new JFrame();
    frame.setUndecorated(true);
    frame.setJMenuBar(menubar);
    frame.setSize(W / 3, H / 3);
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);

    // draw menu bar using standard order.
    final BufferedImage bi1 = step1(menubar);

    // draw menu border on top of the menu bar, nothing should be changed.
    final BufferedImage bi2 = step2(menubar);
    frame.dispose();

    for (int x = 0; x < W; ++x) {
        for (int y = 0; y < H; ++y) {
            if (bi1.getRGB(x, y) != bi2.getRGB(x, y)) {
                try {
                    ImageIO.write(bi1, "png", new File("image1.png"));
                    ImageIO.write(bi2, "png", new File("image2.png"));
                } catch (IOException e) {
                    e.printStackTrace();
                }
                throw new RuntimeException("Failed: wrong color");
            }
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:34,代码来源:MisplacedBorder.java

示例14: createAndShowGUI

import javax.swing.JFrame; //导入方法依赖的package包/类
/**
 * Create the GUI and show it. For thread safety, this method should be
 * invoked from the event-dispatching thread.
 */
private static void createAndShowGUI() {
	// Create and set up the window.
	JFrame frame = new JFrame("MenuDemo");
	frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

	// Create and set up the content pane.
	GeometricTreeDemo demo = new GeometricTreeDemo();
	frame.setJMenuBar(demo.createMenuBar());
	frame.setContentPane(demo.createContentPane());

	// Display the window.
	frame.setSize(450, 260);
	frame.setVisible(true);
}
 
开发者ID:hughxie,项目名称:class-code,代码行数:19,代码来源:GeometricTreeDemo.java

示例15: createFrame

import javax.swing.JFrame; //导入方法依赖的package包/类
/**
 * 
 */
public JFrame createFrame(JMenuBar menuBar)
{
	JFrame frame = new JFrame();
	frame.getContentPane().add(this);
	frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	frame.setJMenuBar(menuBar);
	frame.setSize(870, 640);

	// Updates the frame title
	updateTitle();

	return frame;
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:17,代码来源:BasicGraphEditor.java


注:本文中的javax.swing.JFrame.setJMenuBar方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。