-
Bug
-
Resolution: Duplicate
-
P4
-
None
-
1.2.0
-
generic
-
generic
Name: clC74495 Date: 02/24/99
In JDK 1.2 as well as Swing 1.1.1 Beta1, if I have a JPanel where
isFocusCycleRoot() returns true:
import javax.swing.*;
public class FocusCycleConstrainedJPanel extends JPanel {
public boolean isFocusCycleRoot() {
return true;
}
}
Shift-Tab sometimes doesn't honor the closed focus cycle in the panel,
it tabs out of the panel.
Sample program follows. It is a 3x3 grid, where middle row is in a different
panel (with the closed focus cycle). [Metal look and feel if it matters.]
Pressing TAB, TAB, TAB, takes me to first component in inner panel. SHIFT-TAB
takes me out of panel, instead of to last component in inner panel.
If I SHIFT-TAB into inner panel from back end, I have yet to have SHIFT-TAB
get me out of panel at beginning.
However, when I TAB into inner panel, then this sometimes, but not always,
allows me to SHIFT-TAB out of panel.
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class FocusCycleSample {
public static void main(String args[]) {
JFrame frame = new JFrame("Focus Cycle Sample");
Container contentPane = frame.getContentPane();
contentPane.setLayout(new GridBagLayout());
GridBagConstraints constraints = new GridBagConstraints();
constraints.weightx = 1.0;
constraints.weighty = 1.0;
constraints.gridwidth = 1;
constraints.gridheight = 1;
constraints.fill = GridBagConstraints.BOTH;
// Row One
constraints.gridy=0;
for (int i=0; i<3; i++) {
JButton button = new JButton("" + i);
constraints.gridx=i;
contentPane.add(button, constraints);
}
// Row Two
JPanel panel = new FocusCycleConstrainedJPanel();
panel.setLayout(new GridLayout(1,3));
for (int i=0; i<3; i++) {
JButton button = new JButton("" + (i+3));
panel.add(button);
}
constraints.gridx=0;
constraints.gridy=1;
constraints.gridwidth=3;
contentPane.add(panel, constraints);
// Row Three
constraints.gridy=2;
constraints.gridwidth=1;
for (int i=0; i<3; i++) {
JButton button = new JButton("" + (i+6));
constraints.gridx=i;
contentPane.add(button, constraints);
}
frame.setSize(300, 200);
frame.setVisible(true);
}
}
(Review ID: 54635)
======================================================================
- duplicates
-
JDK-4290675 Focus Management Enhancements
- Closed