Thursday, November 24, 2011

Little Password Text Widget ... TriplePlay

Hack around a little bit to get a little Password Text Widget from TriplePlay, again crude but works for me ...
public class PasswordField extends Field {
 @Override 
 protected String getLayoutText () {
        String ltext = text.get();
        // we always want non-empty text so that we force ourselves to always have a text layer and
        // sane dimensions even if the text field contains no text
        if (ltext == null || ltext.length() == 0) {
         return " "; 
        }
        StringBuffer r = new StringBuffer();
        for (int a=0; a<ltext.length(); a++) {
         r.append("*");
        }
        return r.toString();
    } 
}

No comments:

Post a Comment