Login  Register

Re: Making password fields in GenericDialogs

Posted by dscho on Jul 22, 2005; 5:43pm
URL: http://imagej.273.s1.nabble.com/Making-password-fields-in-GenericDialogs-tp3705203p3705204.html

Hi,

On Fri, 22 Jul 2005, Jeff Brandenburg wrote:

> As a workaround, I've made a subclass of GenericDialog, adding the
> following method:
>
>    public void makePasswordField() {
>      if (stringField.size() > 0) {
>        TextField tf = (TextField)
> this.stringField.elementAt(this.stringField.size()-1);
>        tf.setEchoChar('*');
>      }
>    }

How about something like this instead:

public void addPasswordField(String label, String default) {
        addStringField(label,default);
        TextField tf = (TextField)stringField.elementAt(stringField.size()-1);
        tf.setEchoChar('*');
}

BTW I would vote against changing GenericDialog: It is just not meant to
handle dialogs independent from image processing. Besides, I don't think
it is a kludge to extend GenericDialog to your needs by inheriting it.

Ciao,
Dscho