Java Code Examples for javax.swing.JFrame.getJMenuBar()

The following are Jave code examples for showing how to use getJMenuBar() of the javax.swing.JFrame class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: incubator-netbeans   File:   View Source Code Vote up 7 votes
public boolean postProcessKeyEvent(KeyEvent ev) {
    if (ev.isConsumed())
        return false;

    if (processShortcut(ev))
        return true;

    Window w = SwingUtilities.windowForComponent(ev.getComponent());        
    if (w instanceof Dialog && !WindowManagerImpl.isSeparateWindow(w))
        return false;
    JFrame mw = (JFrame)WindowManagerImpl.getInstance().getMainWindow();
    if (w == mw) {
        return false;

    JMenuBar mb = mw.getJMenuBar();
    if (mb == null)
        return false;
    boolean pressed = (ev.getID() == KeyEvent.KEY_PRESSED);        
    boolean res = invokeProcessKeyBindingsForAllComponents(ev, mw, pressed);
    if (res)
    return res;
Example 2
Project: openjdk-jdk10   File:   View Source Code Vote up 6 votes
public void run() {
    final JFrame frame = new DeprecatedFrame();
    try {
        final JMenuBar bar = new JMenuBar();
        frame.setBounds(100, 100, 100, 100);
        if (bar != frame.getJMenuBar()) {
            throw new RuntimeException("Wrong JMenuBar");
    } finally {