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

JPasswordField.setEchoChar() doesn't fully work

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 1.3.0
    • 1.2.0
    • client-libs
    • kestrel
    • x86
    • windows_95



      Name: diC59631 Date: 12/15/98


      I am using a JPasswordField and I allow the user to toggle the character echoing on and off. The JPasswordField supports this
       feature via the setEchoChar() and echoCharIsSet() methods. The AIP claims that using setEchoChar((char)0) will turn off character
      echoing. This is not what it does however. Instead, it changes the echo char to be (char)0, which shows up as the typical
       'empty box' since the font has nothing defined for (char)0. I use the echoCharIsSet() method to determine that after the
      setEchoChar((char)0) call the JPasswordField thinks it has turned off character echoing. The following code snippet shows
      what I have done:

        ...
        JPasswordField jpf = new JPasswordField();
        jpf.setText("Top Secret!!");
        if (jpf.echoCharIsSet()) System.out.ptintln("Echo is set");
        else System.out.println("NO echo set");
        jpf.setEchoChar((char)0);
        if (jpf.echoCharIsSet()) System.out.ptintnl("Echo is set");
        else System.out.println("NO echo set");
        ...

      That results in the output:

         Echo is set
         NO echo set

      Unfortunately, the text in the JPasswordField changes from the default "************" to "^A^A^A^A^A^N^A^A^A^A^A^A" (I used (char)1 since my browser wouldn't let me put in (char)0 into the textarea here, but the effect is the same).
      (Review ID: 43554)
      ======================================================================

            tprinzing Tim Prinzing (Inactive)
            dindrigo Daniel Indrigo (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: