JDK-4425065 : Arrow key navigation in JMenu in JSplitPane doesn't work
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 1.3.0
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic,windows_nt
  • CPU: generic,x86
  • Submitted: 2001-03-13
  • Updated: 2001-04-03
  • Resolved: 2001-04-03
Related Reports
Duplicate :  
Description

Name: ssT124754			Date: 03/13/2001


java version "1.3.0"
Java(TM) 2 Runtime Environment, Standard Edition (build
Java HotSpot(TM) Client VM (build 1.3.0-C, mixed mode)

1. Mouse-select the frame menu or the first panel menu - press UP and DOWN
arrow keys - navigation works.

2. Mouse-select one of the two panel menus in the split pane - press UP and
DOWN arrow keys - navigation does NOT work.

Here is the source:
----------------------------------------------

import java.awt.*;
import javax.swing.*;

public class MenuProblem  {

    static public void main(String argv[])   {
        JFrame jf = new JFrame("Test");
        JMenu jm = new JMenu("Frame Menu");
        JMenuItem jmi1 = new JMenuItem("Frame MenuItem 1");
        JMenuItem jmi2 = new JMenuItem("Frame MenuItem 2");
        JMenuBar menuBar = new JMenuBar();

        jm.add(jmi1);
        jm.add(jmi2);
        menuBar.add(jm);
        jf.setJMenuBar(menuBar);

        jf.getContentPane().setLayout(new BorderLayout());

        jf.getContentPane().add(new panel(), BorderLayout.NORTH );

        JSplitPane jsplit = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,
                                new panel(),
                                new panel());
        jsplit.setTopComponent(new panel());

        jf.getContentPane().add(jsplit, BorderLayout.CENTER);

        jf.setSize(200,200);
        jf.setVisible(true);
    }
}

class panel extends JPanel {

    public  panel() {
        super();
        JMenuBar menuBar = new JMenuBar();
        setLayout(new BorderLayout());
        add(menuBar, BorderLayout.NORTH);
        JMenu jm = new JMenu("Panel Menu");
        menuBar.add(jm);
        jm.add(new JMenuItem("Panel MenuItem1"));
        jm.add(new JMenuItem("Panel MenuItem2"));
    }
}
(Review ID: 118648) 
======================================================================

Comments
EVALUATION This was fixed as part of 4371580. The PopupMenu now gets focus, so that the appropriate bindings are processed instead of JSplitPanes bindings getting in the way. scott.violet@eng 2001-04-03
03-04-2001

WORK AROUND This is caused because JSplitPane has bindings for up/down/left/right... that are used instead of the menus. You can shadow these bindings by doing something like: splitPane.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke("UP"), "foo"); which will make it so that splitpane bindings are not in effect, and that the menu bindings can then be used. scott.violet@eng 2001-04-03
03-04-2001