Example #1
0
 /** Similar to getText() but works properly with password fields */
 private String getTextFieldString(TextField ta) {
   String text = (String) ta.getText();
   String displayText = "";
   if ((ta.getConstraint() & TextArea.PASSWORD) != 0) {
     // show the last character in a password field
     if (ta.isPendingCommit()) {
       if (text.length() > 0) {
         for (int j = 0; j < text.length() - 1; j++) {
           displayText += "*";
         }
         displayText += text.charAt(text.length() - 1);
       }
     } else {
       for (int j = 0; j < text.length(); j++) {
         displayText += "*";
       }
     }
   } else {
     displayText = text;
   }
   return displayText;
 }