本文整理汇总了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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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());
}
}
示例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);
}
示例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");
}
}
}
}
示例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);
}
示例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;
}