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

Esc key doesn't restore old value in JFormattedtextField when ToolTip is set

XMLWordPrintable

    • b03
    • x86
    • windows_2000
    • Verified

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

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows 2000 [Version 5.00.2195]

      A DESCRIPTION OF THE PROBLEM :
      On a JFormattedTextField you have the possibility to restore the old value by pressing the [Esc]-Key before the new value is commited.

      After having set a ToolTip on that JFormattedTextField this functionality doesn't work any longer, i.e. the prvious value isn't restored any longer, event though the new value hasn't been committed yet.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Create an application with a JFormattedTextField. Set a value to the field using the method "setValue". I tried this with a String Argument -> setValue("Bla");

      run the application and edit the field: Position the cursor behind the word (Bla) and type some arbitrary content, no matter what.

      DO NOT COMMIT THE CONTENTS (Pressing Return/ FocusLost), but press the Esc-Key.

      Result: The text displayed in the field shows its initial contents ("Bla")

      Then, add a line after that setValue(..) in which a ToolTipText is set on the JFormattedTextField, for Example "BlaBla".

      Then, edit the field again as described above, and do not commit the new contents. Press Esc again.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The Text is reverted to its old value ("Bla")
      ACTUAL -
      The text isn't reverted. The JFormattedTextField still shows the new, edited Text

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      No crash, no error message

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------

      import javax.swing.JFrame;
      import javax.swing.JPanel;
      import javax.swing.JFormattedTextField;
      import java.awt.HeadlessException;

      public class MainFrame extends JFrame{

          public static void main(String[] args){
              new MainFrame();
          }

          public MainFrame() throws HeadlessException {
              init();
          }

          private void init() {

              this.setSize(400,250);
              this.setLocation(100,100);
              this.setTitle("Test");

              JPanel lContents = new JPanel();
              lContents.setLayout(null);

              JFormattedTextField lField = new JFormattedTextField();
              lField.setBounds(20,20,80,24);
              lContents.add(lField);

              lField.setValue("Bla");

              //Comment/ uncomment the following line to illustrate the effect
              lField.setToolTipText("BlaBla");

              this.getContentPane().add(lContents);
              this.setVisible(true);
          }


      }

      ---------- END SOURCE ----------
      ###@###.### 2005-04-15 20:50:10 GMT

            alexp Alexander Potochkin (Inactive)
            gmanwanisunw Girish Manwani (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: