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

REGRESSION: DocumentFilter is never called in JDK1.4.0-beta3.

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P3
    • Resolution: Not an Issue
    • Affects Version/s: 1.4.0
    • Fix Version/s: None
    • Component/s: client-libs
    • Labels:

      Description



      Name: rmT116609 Date: 01/09/2002


      FULL PRODUCT VERSION :
      java version "1.4.0-beta3"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta3-b84)
      Java HotSpot(TM) Client VM (build 1.4.0-beta3-b84, mixed mode)

      Microsoft Windows 2000 [Version 5.00.2195], Solaris 2.8

      DESCRIPTION OF THE PROBLEM :

      I need to have my own DocumentFilter installed. With JDK1.4 beta everything worked fine, but
      under 1.4 beta 3 my DocumentFilter will never be called.

      REGRESSION. Last worked in version 1.4.0-beta

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1.Compile and run the code snipped below under JDK 1.4 beta and type something into the JFormattedTextField.
      2.Compile and run the code snipped below under JDK 1.4 beta3 and type something into the JFormattedTextField.


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      Under JDK 1.4 beta you will see the debug line "With JDK 1.4 beta 3 insertString will never be called!"
      Running the same with beta3 nothing will happen.

      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.awt.*;
      import javax.swing.*;
      import javax.swing.text.*;
      import java.awt.event.*;

      public class TestFrame extends JFrame {

          public TestFrame() {
              this.getContentPane().setLayout(new BorderLayout());
              JPanel panel = new JPanel(new BorderLayout());
              JFormattedTextField field = new JFormattedTextField();
              try {
                  field.setFormatterFactory(new DefaultFormatterFactory(new MyMaskFormatter("UUUU")));
              } catch (Exception e) {}
              panel.add(field, BorderLayout.CENTER);
              this.getContentPane().add(panel, BorderLayout.CENTER);
              this.resize(300,50);
              this.show();
          }

          private class MyMaskFormatter extends MaskFormatter {
              private DocumentFilter filter;

              public MyMaskFormatter(String mask) throws Exception {
                  super(mask);
              }
              protected DocumentFilter getDocumentFilter() {
                  if (filter == null) {
                      filter = new MyMaskFormatterDocumentFilter(super.getDocumentFilter() );
                  }
                  return filter;
              }
          }

          private class MyMaskFormatterDocumentFilter extends DocumentFilter {
              private DocumentFilter ref;

              public MyMaskFormatterDocumentFilter(DocumentFilter ref) {
                  this.ref = ref;
              }

              public void remove(FilterBypass fb, int offset, int length) throws BadLocationException {
                  ref.remove(fb, offset, length);
              }

              public void insertString(FilterBypass fb, int offset, String string, AttributeSet attr) throws BadLocationException {
                  System.out.println("With JDK 1.4 beta 3 insertString will never be called!");
                  ref.insertString(fb, offset, string, attr);
              }
          }

          public static void main(String[] args) {
              TestFrame test = new TestFrame();
          }

      }

      ---------- END SOURCE ----------
      (Review ID: 138099)
      ======================================================================

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                shickeysunw Shannon Hickey (Inactive)
                Reporter:
                rmandalasunw Ranjith Mandala (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: