<Swing Dev> [Accessibility]Focus unable to traverse in the menubar
Pavel Porvatov
pavel.porvatov at oracle.com
Wed Oct 5 15:38:51 UTC 2011
Hi Neil and Jing,
> On Mon, 2011-09-19 at 13:52 +0400, Pavel Porvatov wrote:
>> Hi Jing,
>>
>> I can't agree with you about the problem. According to
>> http://download.oracle.com/javase/tutorial/uiswing/components/menu.html
>> "Menus are unique in that, by convention, they aren't placed with the
>> other components in the UI". Instead, a menu usually appears either in a
>> menu bar or as a popup menu", so your test-case is invalid.
> Hi Pavel,
> I'm not sure I understand your objection to the testcase.
>
> As you can see from the testcase code, the JMenu component _is_ held by
> a JMenuBar component, in concordance with the documentation you point
> to.
Yep, that was my mistake. BTW the test treats with JMenu in a strange
way. Actually the test should contain something like this:
JMenuBar menubar = new JMenuBar();
JMenu jMenu = new JMenu("sample menu");
jMenu.add(new JMenuItem("hello"));
menubar.add(jMenu);
> Perhaps you're worried that the physical layout of the components in the
> panel materially affects the nature of the problem being reported ?
>
> If so, please consider the modified testcase in an update to the webrev
> I previously posted [2].
>
> The modification uses the BorderLayout manager instead of GridLayout,
> adding the JMenuBar so that it appears at the top of the panel.
>
> You'll notice that this rearrangement in physical layout does not change
> the nature of the problem being reported.
>
> Hope this helps to clarify things,
> Regards, Neil
The fix changes default value of the JMenuBar.Focusable field and so it
breaks backward compatibility.
Moreover the test have many other problems, but not only in JMenuBar:
1. Shift-TAB doesn't work from JComboBox
2. TAB from the last Button moves focus to some non-interactive
component and next TAB pressing doesn't change focus state at all
May be the ContainerOrderFocusTraversalPolicy should be fixed...?
P.S. CC-ed Anton as a focus expert
More information about the swing-dev
mailing list