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

TextField.setEchoCharacter() seems to be broken

XMLWordPrintable

    • 1.2.2
    • sparc
    • solaris_2.6


      gordon.jackson@east 1999-03-19

      I am seeing a problem with TextField.setEchoCharacter() in my
      tests. Specifically, only one character is echoed ans after the second
      character is typed, the system beeps at me. The result is that what I
      am trying to enter into the textfield is not being correctly
      received. Other textfields in the same dialog do not have this
      problem, just the one where I setEchoCharacter('*').

      Here is the source for the dialog in question:

      import java.awt.*;

      public class ConnectDialog extends Dialog {

          public ConnectDialog(Frame parent) {

              super(parent, "Connection Strings", false);
              setLayout(null);
              addNotify();
              resize(502,229);
              label1=new Label("User ID:", Label.RIGHT);
              add(label1);
              label1.reshape(25,30,130,21);
              tfUserID=new TextField(31);
              tfUserID.setFont(new Font("Courier",Font.PLAIN,12));
              add(tfUserID);
              tfUserID.reshape(172,30,262,33);
              label2=new Label("Password", Label.RIGHT);
              add(label2);
              label2.reshape(25,75,130,21);
              tfPassword=new TextField(31);
              add(tfPassword);
              tfPassword.reshape(172,75,262,33);
              label3=new Label("Connection URL:", Label.RIGHT);
              add(label3);
              label3.reshape(25,120,130,21);
              tfUrl=new TextField(31);
              add(tfUrl);
              tfUrl.reshape(172,120,262,33);
              button1=new Button("OK");
              add(button1);
              button1.reshape(140,165,140,23);
        

           setResizable(false);
           tfPassword.setEchoCharacter('*');
          }

          public synchronized void show() {
           Rectangle bounds = getParent().bounds();
           Rectangle abounds = bounds();

           move(bounds.x + (bounds.width - abounds.width)/ 2,
           bounds.y + (bounds.height - abounds.height)/2);

           super.show();
          }

          public synchronized void wakeUp() {
           notify();
          }

          public boolean handleEvent(Event event) {
           if (event.id == Event.ACTION_EVENT && event.target == button1) {
      clickedOKButton();
      return true;
           }
           else

      if (event.id == Event.WINDOW_DESTROY) {
      hide();
      return true;
      }
           return super.handleEvent(event);
          }

         
          Label label1;
          TextField tfUserID;
          Label label2;
          TextField tfPassword;
          Label label3;
          TextField tfUrl;
          Button button1;
          
          public void clickedOKButton() {
              hide();
          }
          public String getUserID() {
      return tfUserID.getText();
          }

          public String getPassword() {
      return tfPassword.getText();
          }

          public String getUrl() {
              return tfUrl.getText();
          }
      }

            mbronsonsunw Mike Bronson (Inactive)
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: