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

JFormattedTextField with mask of "U" doesn't handle Delete properly

XMLWordPrintable

    • 6
    • x86
    • linux

      FULL PRODUCT VERSION :
      java version "1.6.0_12"
      Java(TM) SE Runtime Environment (build 1.6.0_12-b04)
      Java HotSpot(TM) Server VM (build 11.2-b01, mixed mode)


      ADDITIONAL OS VERSION INFORMATION :
      2.6.28-15-generic #52-Ubuntu SMP Wed Sep 9 10:49:34 UTC 2009 i686 GNU/Linux


      EXTRA RELEVANT SYSTEM CONFIGURATION :
      Happens on Windows also

      A DESCRIPTION OF THE PROBLEM :
      We are using a JFormattedTextField with a mask of "U" to enter the Middle Initial.
      A user wanted to change an existing Middle initial so they tabbed to the field and pressed the Delete key when the cursor was to the left of the single Upper Cased letter.
      After pressing Delete the field contains a single blank character and you have to press Backspace to get rid of that so that you can enter the new value.
      Of course rather than pressing Delete, the user could just type the new value. But most users expect to have to press Delete.

      You can duplicate the problem with this code:
              JFormattedTextField ftf = new JFormattedTextField(createFormatter("U"));

      // This code is direct from the section on JFormattedTextField in the Java Tutorial

          protected MaskFormatter createFormatter(String s) {
              MaskFormatter formatter = null;
              try {
                  formatter = new MaskFormatter(s);
              } catch (java.text.ParseException exc) {
                  System.err.println("formatter is bad: " + exc.getMessage());
                  System.exit(-1);
              }
              return formatter;
          }


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      It's all in Description

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Upon pressing Delete the field would be empty and allow entry of the one character
      ACTUAL -
      Field contains a Blank which must be deleted

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      see description
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      as described in Description

            Unassigned Unassigned
            ndcosta Nelson Dcosta (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: