-
Enhancement
-
Resolution: Fixed
-
P4
-
1.3.1
-
hopper
-
generic
-
generic
-
Verified
JTextArea, JTextPane, etc. swallow the Tab key. This makes sense when editing
is allowed, but when the component is uneditable, it causes unneeded frustration and damages keyboard accessibility.
Forcing the user to type Control+Tab is needlessly complex.
This is a very easy fix:
myTextComponent = new javax.swing.JTextPane {
//override this so tab is not swallowed by this component
public boolean isManagingFocus() {
return false;
}
};
=========
Test case
-- TextTest.java
import java.awt.event.*;
import javax.swing.*;
import javax.swing.text.*;
public class TextTest {
static JTextComponent ed;
public static void main(String[] args) {
JFrame f = new JFrame("test");
f.setVisible(true);
JDialog frame = new JDialog(f,"TextTest");
JButton button = new JButton("west");
frame.getContentPane().add(button,BorderLayout.WEST);
button = new JButton("button");
frame.getContentPane().add(button,BorderLayout.SOUTH);
button.addActionListener(
new ActionListener() {
public void actionPerformed(ActionEvent ae) {
System.out.println("button pressed "+ae);
ed.setEditable(!ed.isEditable());
}
});
frame.getRootPane().setDefaultButton(button);
JTextComponent editor = new JTextArea("JTextArea");
ed = editor;
editor.setEditable(false);
//editor.disable();
frame.getContentPane().add(editor,BorderLayout.NORTH);
editor = new JTextArea("JTextArea");
editor.setEditable(false);
//editor.disable();
frame.getContentPane().add(editor,BorderLayout.CENTER);
frame.pack();
frame.setVisible(true);
}
}
--
Steps to reproduce.
1. run TextTest
2. select textArea by mouse
4. press tab
5. focus should move to next component
###@###.### 2002-04-19
is allowed, but when the component is uneditable, it causes unneeded frustration and damages keyboard accessibility.
Forcing the user to type Control+Tab is needlessly complex.
This is a very easy fix:
myTextComponent = new javax.swing.JTextPane {
//override this so tab is not swallowed by this component
public boolean isManagingFocus() {
return false;
}
};
=========
Test case
-- TextTest.java
import java.awt.event.*;
import javax.swing.*;
import javax.swing.text.*;
public class TextTest {
static JTextComponent ed;
public static void main(String[] args) {
JFrame f = new JFrame("test");
f.setVisible(true);
JDialog frame = new JDialog(f,"TextTest");
JButton button = new JButton("west");
frame.getContentPane().add(button,BorderLayout.WEST);
button = new JButton("button");
frame.getContentPane().add(button,BorderLayout.SOUTH);
button.addActionListener(
new ActionListener() {
public void actionPerformed(ActionEvent ae) {
System.out.println("button pressed "+ae);
ed.setEditable(!ed.isEditable());
}
});
frame.getRootPane().setDefaultButton(button);
JTextComponent editor = new JTextArea("JTextArea");
ed = editor;
editor.setEditable(false);
//editor.disable();
frame.getContentPane().add(editor,BorderLayout.NORTH);
editor = new JTextArea("JTextArea");
editor.setEditable(false);
//editor.disable();
frame.getContentPane().add(editor,BorderLayout.CENTER);
frame.pack();
frame.setVisible(true);
}
}
--
Steps to reproduce.
1. run TextTest
2. select textArea by mouse
4. press tab
5. focus should move to next component
###@###.### 2002-04-19
- relates to
-
JDK-4838730 REGRESSION: In JTextArea setEditable(...) breaks focus traversal keys
-
- Resolved
-
-
JDK-8281745 Create a regression test for JDK-4514331
-
- Resolved
-