Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4514331

Non-editable JTextArea and similar should allow Tab to keyboard - accessibility

    Details

    • Type: Enhancement
    • Status: Closed
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 1.3.1
    • Fix Version/s: 1.4.1
    • Component/s: client-libs
    • Labels:
    • Subcomponent:
    • Resolved In Build:
      hopper
    • CPU:
      generic
    • OS:
      generic
    • Verification:
      Verified

      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

      ###@###.### 2002-04-19

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                idk Igor Kushnirskiy (Inactive)
                Reporter:
                duke J. Duke (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: