|
Quick Lists
|
|
Bug ID:
|
4514331
|
|
Votes
|
3
|
|
Synopsis
|
Non-editable JTextArea and similar should allow Tab to keyboard - accessibility
|
|
Category
|
java:classes_swing
|
|
Reported Against
|
1.3.1
|
|
Release Fixed
|
1.4.1(hopper)
|
|
State
|
10-Fix Delivered,
Verified,
request for enhancement
|
|
Priority:
|
4-Low
|
|
Related Bugs
|
4838730
|
|
Submit Date
|
12-OCT-2001
|
|
Description
|
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
xxxxx@xxxxx 2002-04-19
|
|
Work Around
|
N/A
|
|
Evaluation
|
Sounds like a good idea
xxxxx@xxxxx 2001-11-13
==========================
Giving a second thought, I do not think that it is such a good idea.
What if user wants to select text in noneditable text component?
I think that by default text component should be accessible using Tab no matter
editable they or not.
closing as 'will not fix'
xxxxx@xxxxx 2002-04-03
Let me clarify. Tab is not required for selecting text. It is only useful for typing text, which is not allowed in an uneditable text area. You can allow text selection and yet still not swallow the tab key.
xxxxx@xxxxx 2002-04-03
|
|
Comments
|
Submitted On 21-FEB-2002
carej
A better solution would be for JTextArea, JTextPane, etc. to
change their implementation to be:
public boolean isManagingFocus () {
return isEditable ();
}
By doing so, editable text components will still swallow
tabs as needed, but non-editable ones will allow the
expected behavior.
Also note that under some Linux window managers, CNTL-TAB
is trapped by the window manager for it's own use (e.g.
CNTL-TAB will switch virtual desktops under KDE).
Submitted On 23-APR-2002
porcaree
The above example does not work. I cannot TAB out of the
JTextAreas without pressing the Ctrl-TAB combination. The
default windows behavior is that a user can TAB out of a
multiline text area by just pressing the TAB key, and to
create a tab character within the text area the user would
press the Ctrl-TAB combination. Regarding the work-around
by overriding isManagingFocus(), this is not a good idea
because returning false disables the ability to select text
and/or copy and paste text. I believe it is important to
change the JTextArea tab behavior because java
accessibility applications should use the same standards as
other windows applications. Our java applications have to
use accessibility standards, and tabbing to go the next
focusable component from JTextArea would be the more
frequently used than having to place a TAB character within
the JTextArea. Having to frequently press Ctrl-TAB to move
out of a JTextArea can pose problems and inefficiencies for
people with accessibility issues. Because of this I propose
that the TAB and Ctrl-TAB default behavior be switched to
match the default windows behavior mentioned above.
Submitted On 15-JUL-2003
sssako
your shit doesnt work.
Submitted On 13-FEB-2009
Georgy_Dimitrov
To switch TAB and Ctrl-TAB default behavior.
I use this:
//Create new text area
JTextArea _text = new JTextArea ();
//Set Tab key as focus traversal key
TreeSet _newKeys = new TreeSet(); _newKeys.add(KeyStroke.getKeyStroke(KeyEvent.VK_TAB,0));
text.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS,_newKeys);
//Control+Tab to inset tabulator
text.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, KeyEvent.CTRL_DOWN_MASK),DefaultEditorKit.insertTabAction);
//Remove old Tab behavour
text.getInputMap().remove(KeyStroke.getKeyStroke(KeyEvent.VK_TAB,0));
PLEASE NOTE: JDK6 is formerly known as Project Mustang
|
|
|
 |