|
Description
|
FULL PRODUCT VERSION :
java version "1.4.0-beta3"
Java(TM) 2 Runtime Environment, Standard Edition (build
1.4.0-beta3-b84)
Java HotSpot(TM) Client VM (build 1.4.0-beta3-b84, mixed
mode)
FULL OPERATING SYSTEM VERSION :
Windows Millennium [Version 4.90.3000]
A DESCRIPTION OF THE PROBLEM :
Mnemonics on JTabbedPane tabs are now supported.
However, it seems that they only work when
the tabbed pane or one of its children has
the focus.
Why I think this is wrong:
1. In a frame/dialog that contains a tabbed pane
there might be other components that may have
the focus and the user might wish to transfer
the focus from one of those components (text field,
button, ...) to the tabbed pane or a specific
tab in the tabbed pane using the keyboard.
Certainly this would be useful.
2. Tab mnemonics are visible on the screen
(the character is underlined) and the user expects
visible mnemonics to work (just like they do
on buttons or menus), no matter where the focus is.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the attached test case.
Try to activate the tab mnemonics by pressing
ALT+T or ALT+S while the 'Name' text field
or the 'OK' button has the focus. It won't work.
EXPECTED VERSUS ACTUAL BEHAVIOR :
Using the mnemonics associated with one of the tabs
should result in the specific tab being selected
even if the focus wasn't in the tabbed pane before.
With the current implementation, this isn't the case.
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.*;
public class TestDialog extends JDialog {
private JPanel pnl;
private JPanel namePnl;
private JLabel nameLbl;
private JTextField nameTxtFld;
private JTabbedPane tbbdPn;
private JPanel dlgButPnl;
private JButton okBut;
public TestDialog() {
super((Frame) null, "Title", true);
pnl = new JPanel();
pnl.setBorder(new EmptyBorder(9, 6, 5, 5));
pnl.setLayout(new GridBagLayout());
namePnl = new JPanel();
namePnl.setLayout(new GridBagLayout());
nameLbl = new JLabel("Name:");
nameLbl.setDisplayedMnemonic('m');
namePnl.add(nameLbl, new GridBagConstraints(
GridBagConstraints.RELATIVE, 0, 1, 1, 0, 0,
GridBagConstraints.CENTER,
GridBagConstraints.NONE,
new Insets(0, 0, 0, 0), 0, 0));
namePnl.add(Box.createHorizontalStrut(6), new
GridBagConstraints(
GridBagConstraints.RELATIVE, 0, 1, 1, 0, 0,
GridBagConstraints.CENTER,
GridBagConstraints.NONE,
new Insets(0, 0, 0, 0), 0, 0));
nameTxtFld = new JTextField();
nameLbl.setLabelFor(nameTxtFld);
namePnl.add(nameTxtFld, new GridBagConstraints(
GridBagConstraints.RELATIVE, 0, 1, 1, 1, 0,
GridBagConstraints.CENTER,
GridBagConstraints.HORIZONTAL,
new Insets(0, 0, 0, 0), 0, 0));
pnl.add(namePnl, new GridBagConstraints(
0, GridBagConstraints.RELATIVE, 1, 1, 1, 0,
GridBagConstraints.CENTER,
GridBagConstraints.HORIZONTAL,
new Insets(0, 9, 0, 9), 0, 0));
JSeparator sep = new JSeparator();
pnl.add(sep, new GridBagConstraints(
0, GridBagConstraints.RELATIVE, 1, 1, 1, 0,
GridBagConstraints.CENTER,
GridBagConstraints.HORIZONTAL,
new Insets(7, 9, 3, 9), 0, 0));
tbbdPn = new JTabbedPane();
tbbdPn.addTab("Tab 1", new JTextArea("Dingo"));
tbbdPn.setMnemonicAt(0, KeyEvent.VK_T);
tbbdPn.addTab("Tab 2", new JTextArea("Manga"));
tbbdPn.setMnemonicAt(1, KeyEvent.VK_B);
pnl.add(tbbdPn, new GridBagConstraints(
0, GridBagConstraints.RELATIVE, 1, 1, 1, 1,
GridBagConstraints.CENTER, GridBagConstraints.BOTH,
new Insets(0, 0, 0, 1), 0, 0));
pnl.add(Box.createVerticalStrut(6), new
GridBagConstraints(
0, GridBagConstraints.RELATIVE, 1, 1, 0, 0,
GridBagConstraints.CENTER, GridBagConstraints.NONE,
new Insets(0, 0, 0, 0), 0, 0));
dlgButPnl = new JPanel();
dlgButPnl.setLayout(new GridLayout(1, 0, 5, 0));
okBut = new JButton("OK");
okBut.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
setVisible(false);
}
});
getRootPane().setDefaultButton(okBut);
dlgButPnl.add(okBut);
pnl.add(dlgButPnl, new GridBagConstraints(
0, GridBagConstraints.RELATIVE, 1, 1, 1, 0,
GridBagConstraints.CENTER,
GridBagConstraints.HORIZONTAL,
new Insets(0, 0, 0, 0), 0, 0));
setContentPane(pnl);
setSize(new Dimension(384, 496));
}
public static void main(String[] args) {
new TestDialog().show();
}
}
---------- END SOURCE ----------
(Review ID: 137758)
======================================================================
|