Tabnine Logo
JFrame.setJMenuBar
Code IndexAdd Tabnine to your IDE (free)

How to use
setJMenuBar
method
in
javax.swing.JFrame

Best Java code snippets using javax.swing.JFrame.setJMenuBar (Showing top 20 results out of 1,134)

Refine searchRefine arrow

  • JMenuBar.<init>
  • JMenuBar.add
  • JMenu.<init>
  • JMenu.add
  • JFrame.setDefaultCloseOperation
  • Window.setVisible
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: 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

/**
 * 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: jMonkeyEngine/jmonkeyengine

private static void createMenu(){
  JMenuBar menuBar = new JMenuBar();
  frame.setJMenuBar(menuBar);
  JMenu menuTortureMethods = new JMenu("Canvas Torture Methods");
  menuBar.add(menuTortureMethods);
  menuTortureMethods.add(itemRemoveCanvas);
  itemRemoveCanvas.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
  menuTortureMethods.add(itemHideCanvas);
  itemHideCanvas.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
  menuTortureMethods.add(itemSwitchTab);
  itemSwitchTab.addActionListener(new ActionListener(){
    public void actionPerformed(ActionEvent e){
origin: stackoverflow.com

JMenu menu = new JMenu("Other");
menu.add(screenshot);
JMenuBar mb = new JMenuBar();
mb.add(menu);
f.setJMenuBar(mb);
f.pack();
f.setLocationRelativeTo(null);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setVisible(true);
origin: pmd/pmd

JMenu fileMenu = new JMenu("File");
fileMenu.setMnemonic('f');
exitItem.setMnemonic('x');
exitItem.addActionListener(new CancelListener());
fileMenu.add(exitItem);
JMenu viewMenu = new JMenu("View");
fileMenu.setMnemonic('v');
JMenuItem trimItem = new JCheckBoxMenuItem("Trim leading whitespace");
viewMenu.add(trimItem);
JMenuBar menuBar = new JMenuBar();
menuBar.add(fileMenu);
menuBar.add(viewMenu);
frame.setJMenuBar(menuBar);
frame.getContentPane().add(topPanel, BorderLayout.NORTH);
frame.getContentPane().add(resultsPanel, BorderLayout.CENTER);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack();
frame.setVisible(true);
origin: cmusphinx/sphinx4

private static void createMenuBar(JFrame jframe) {
  JMenuBar menuBar = new JMenuBar();
  jframe.setJMenuBar(menuBar);
  JMenu menu = new JMenu("File");
  menuBar.add(menu);
  menu.add(menuItem);
  menu.add(saveMenuItem);
  menu.add(menuItem);
  menu = new JMenu("Edit");
  menuBar.add(menu);
  menu = new JMenu("View");
  menuBar.add(menu);
origin: stackoverflow.com

File[] files = userDir.listFiles();
JMenu menu = new JMenu("Recent Files");
JToolBar toolBar = new JToolBar(JToolBar.VERTICAL);
JLabel label = new JLabel(" ", JLabel.CENTER);
  if (f.isFile() && !f.isHidden()) {
    RecentFile rf = new RecentFile(f, label);
    menu.add(new JMenuItem(rf.getAction()));
    toolBar.add(rf.getAction());
JMenuBar menuBar = new JMenuBar();
menuBar.add(menu);
f.setJMenuBar(menuBar);
f.add(toolBar, BorderLayout.CENTER);
f.add(label, BorderLayout.SOUTH);
f.pack();
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setLocationRelativeTo(null);
f.setVisible(true);
origin: apache/geode

private void createMenu() {
 JMenuBar menuBar = new JMenuBar();
 JMenu sequenceMenu = new JMenu("Sequence");
 sequenceMenu.setMnemonic(KeyEvent.VK_S);
 sequenceMenu.getAccessibleContext()
   .setAccessibleDescription("The only menu in this program that has menu items");
 menuBar.add(sequenceMenu);
 JMenuItem selectGraphs = new JMenuItem("Choose Graphs", KeyEvent.VK_G);
 selectGraphs.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_G, ActionEvent.ALT_MASK));
 selectGraphs.getAccessibleContext().setAccessibleDescription("Select what graphs to display");
 selectGraphs.setActionCommand("selectgraphs");
 selectGraphs.addActionListener(new ActionListener() {
  @Override
  public void actionPerformed(ActionEvent e) {
   showGraphSelector();
  }
 });
 sequenceMenu.add(selectGraphs);
 frame.setJMenuBar(menuBar);
}
origin: wiztools/rest-client

private void createMenu(){
  JMenu jm_file = new JMenu("File");
  jm_file.setMnemonic(KeyEvent.VK_F);
  jm_file.add(jmi_open_req);
  jm_file.add(jmi_open_res);
  jm_file.add(jmi_open_archive);
  final JMenu jm_open_recent = new JMenu("Open recent");
  jm_open_recent.addMenuListener(new MenuListener() {
  JMenu jm_edit = new JMenu("Edit");
  jm_edit.setMnemonic(KeyEvent.VK_E);
  JMenuBar jmb = new JMenuBar();
  jmb.add(jm_file);
  jmb.add(jm_edit);
  jmb.add(jm_history);
  jmb.add(jm_tools);
  jmb.add(jm_help);
  frame.setJMenuBar(jmb);
origin: stackoverflow.com

JMenuBar menuBar = new JMenuBar();
JMenu menu = new JMenu("Menu");
BufferedImage image = ImageIO.read(new URL("http://pscode.org/media/stromlo1.jpg"));
menu.setHorizontalTextPosition(SwingConstants.CENTER);
menu.setVerticalTextPosition(SwingConstants.BOTTOM);
menu.setIcon(new ImageIcon(image));
menuBar.add(menu);
menu.add(item);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setJMenuBar(menuBar);
frame.setSize(500, 550);
frame.setVisible(true);
origin: stackoverflow.com

dm.setBorder(BorderFactory.createLineBorder(Color.blue, 10));
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.add(dm);
frame.pack();
frame.setLocationByPlatform(true);
JMenuBar menuBar = new JMenuBar();
JMenu fileMenu = new JMenu("File");
menuBar.add(fileMenu);
frame.setJMenuBar(menuBar);
frame.setVisible(true);
origin: stackoverflow.com

setSize(600, 600);
setLocationRelativeTo(null);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container pane = getContentPane();
pane.setLayout(new BorderLayout());
ta.setWrapStyleWord(true);
setJMenuBar(menuBar);
menuBar.add(fileM);
menuBar.add(editM);
menuBar.add(viewM);
fileM.add(saveI);
fileM.add(loadI);
fileM.add(exitI);
editM.add(cutI);
statusI.addActionListener(this);
setVisible(true);
origin: stackoverflow.com

private JMenuBar menuBar = new JMenuBar();
private JMenu fileMenu = new JMenu();
private StatusBar statusBar = new StatusBar();
private ViewDisplayText displayText = new ViewDisplayText();
 menuBar.add(fileMenu);
 frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
 frame.getContentPane().add(displayText.getMainComponent(), BorderLayout.CENTER);
 frame.getContentPane().add(statusBar.getComponent(), BorderLayout.PAGE_END);
 frame.setJMenuBar(menuBar);
 frame.pack();
 frame.setLocationRelativeTo(null);
 frame.setVisible(true);
public void setOpenFileAction(Action action) {
 displayText.setOpenFileButtonAction(action);
 fileMenu.add(new JMenuItem(action));
public void setSaveToFileAction(Action action) {
 displayText.setSaveToFileAction(action);
 fileMenu.add(new JMenuItem(action));
public void setExitAction(Action exitAction) {
 displayText.setExitAction(exitAction);
 fileMenu.add(new JMenuItem(exitAction));
origin: camunda/camunda-bpm-platform

final JMenuBar menuBar = new JMenuBar();
setJMenuBar(menuBar);
final JMenu menu = new JMenu("File");
menuBar.add(menu);
  menu.add(loadMenuItem);
  loadMenuItem.addActionListener(lxa);
} catch (NoClassDefFoundError e) {
menu.add(exitMenuItem);
exitMenuItem.addActionListener(ExitAction.INSTANCE);
origin: stackoverflow.com

frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setJMenuBar(createMenuBar());
frame.setVisible(true);
JMenuBar menuBar = new JMenuBar();
JMenu menu = new JMenu("Frame");
menu.setMnemonic(KeyEvent.VK_N);
JMenuItem menuItem = new JMenuItem("New IFrame");
menu.add(menuItem);
menuBar.add(menu);
return menuBar;
origin: stackoverflow.com

ShowDialog = new JMenuItem(" Show Dialog ");
ShowDialog.addActionListener(showingDialog());
File = new JMenu(" File ");
File.add(Exit);
File.add(ShowDialog);
MenuBar = new JMenuBar();
MenuBar.add(File);
frame.addWindowListener(exitListener);
frame.setDefaultCloseOperation(EXIT_ON_CLOSE);
frame.setJMenuBar(MenuBar);
frame.setPreferredSize(new Dimension(400, 300));
frame.setLocation(100, 100);
frame.pack();
frame.setVisible(true);
SwingUtilities.invokeLater(new Runnable() {
origin: stackoverflow.com

 JFrame myframe = new JFrame();
JMenuBar menubar = new JMenuBar();
JMenu menu = new JMenu("size");
JMenuItem size = new JMenuItem("size");
menu.add(size);
menubar.add(menu);
myframe.setJMenuBar(menubar);
origin: stackoverflow.com

 public final class Application{
   static JFrame mainFrame;                            //static attribute 
   public static void start(){
     //Empty screen with menu
     SwingUtilities.invokeAndWait(() -> {
        JFrame frame = new JFrame("Main frame");
        mainFrame = frame;                        //Storing in static attribute
        JMenuBar menuBar = new JMenuBar();
        JMenu menu = new JMenu("Start");
        menuBar.add(menu);
        frame.setJMenuBar(menuBar);
     });
   }
}
origin: stackoverflow.com

public class MyProgram {
 JFrame frame;
 public MyProgram() {
   ...
   frame = new JFrame();
   JMenuBar mainMenu = new JMenuBar();
   JMenu fileMenu = new JMenu("File");
   fileMenu.add(new JMenuItem("Open..."));
   mainMenu.add(fileMenu); // adds a single JMenu to the menubar
   frame.setJMenuBar(mainMenu); // adds the entire menubar to the window
   ...
   frame.setVisible();
   ...
 }
javax.swingJFramesetJMenuBar

Popular methods of JFrame

  • <init>
  • setVisible
  • setDefaultCloseOperation
  • pack
  • getContentPane
  • setSize
  • add
  • addWindowListener
  • dispose
  • setTitle
  • setContentPane
  • setLocation
  • setContentPane,
  • setLocation,
  • setLocationRelativeTo,
  • setLayout,
  • setResizable,
  • setIconImage,
  • setBounds,
  • getRootPane,
  • getSize

Popular in Java

  • Reading from database using SQL prepared statement
  • notifyDataSetChanged (ArrayAdapter)
  • getSharedPreferences (Context)
  • getSystemService (Context)
  • Font (java.awt)
    The Font class represents fonts, which are used to render text in a visible way. A font provides the
  • Runnable (java.lang)
    Represents a command that can be executed. Often used to run code in a different Thread.
  • URLConnection (java.net)
    A connection to a URL for reading or writing. For HTTP connections, see HttpURLConnection for docume
  • Scanner (java.util)
    A parser that parses a text string of primitive types and strings with the help of regular expressio
  • Semaphore (java.util.concurrent)
    A counting semaphore. Conceptually, a semaphore maintains a set of permits. Each #acquire blocks if
  • Annotation (javassist.bytecode.annotation)
    The annotation structure.An instance of this class is returned bygetAnnotations() in AnnotationsAttr
  • Top 17 Free Sublime Text Plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now