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

NPE thrown in JFormattedTextField on calling setText(null)

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      tiger
    • CPU:
      x86
    • OS:
      windows_2000

      Description

      I am trying to make a test case that will check all 8 mask of
      MaskFormatter for JFormattedTextField.
      I have a JFormattedTextField with MaskFormatter (with (###) ###-####
      mask ) as the formatter JFTF.
      When I call ftf.setText(null) for this mask, it is giving me NPE
      .
      Steps to reproduce:
      -------------------
      1) Compile and Run the attached code.

      Other details are :
       
       OS- Win2k Prof
       
       Java Versions:
       (1)
       java version "swing-jcg-win-01-2003-08-09-int.tiger" Java(TM) 2 Runtime Environment, Standard Edition (build swing-jcg-win-01-2003-08 -09-int.tiger)
       Java HotSpot(TM) Client VM (build 1.5.0-beta-b14, mixed mode)
       
       (2)
       
       java version "1.5.0-beta"
       Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta-b15)
       Java HotSpot(TM) Client VM (build 1.5.0-beta-b15, mixed mode)

      The stack trace of the NPE is as Follows:

      java.lang.NullPointerException
              at javax.swing.text.MaskFormatter.isLiteral(MaskFormatter.java:561)
              at javax.swing.text.MaskFormatter.canReplace(MaskFormatter.java:730)
              at javax.swing.text.DefaultFormatter.replace(DefaultFormatter.java:561)
              at javax.swing.text.DefaultFormatter.replace(DefaultFormatter.java:534)
              at javax.swing.text.DefaultFormatter$DefaultDocumentFilter.replace(DefaultFormatter.java:738)
              at javax.swing.text.AbstractDocument.replace(AbstractDocument.java:660)
              at javax.swing.text.JTextComponent.setText(JTextComponent.java:1411)
              at FormattedSample_Mask.testFormattedNumber(FormattedSample_Mask.java:415)
              at FormattedSample_Mask.runTest(FormattedSample_Mask.java:145)
              at FormattedSample_Mask.<init>(FormattedSample_Mask.java:138)
              at FormattedSample_Mask.main(FormattedSample_Mask.java:31)

      It is also observed on Linux RH and Solaris.

        Attachments

          Activity

            People

            Assignee:
            apikalev Andrey Pikalev
            Reporter:
            mjoshisunw Mayank Joshi (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: