logo       

Making password fields in GenericDialogs: msg#00180

Subject: Making password fields in GenericDialogs
Hi, Wayne, everybody --

I'm working on a plugin that loads and displays images from a Tomcat/JSP Web server. Users will sometimes leave ImageJ idle long enough for a session to expire, and I need to re-authenticate, which entails prompting for a username and password. I'd like to take advantage of the GenericDialog facility, but that doesn't offer an addPasswordField() method.

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('*');
    }
  }

Calling this method sets the echoChar for the last stringField added to the dialog. (Fortunately, stringField is protected, not private, so I can get away with this.)

I can use this method as follows:

  ReauthorizationDialog d = new ReauthorizationDialog("Hey!");
  d.addMessage("Your session has expired.");
  d.addStringField("Username:", "");
  d.addStringField("Password:", "");
  d.makePasswordField();

I could, of course, add further fields after this -- makePasswordField() only affects the last string field added before it's called.

This works, although it's pretty much of a kludge. Wayne, would it be worthwhile adding this to GenericDialog, or adding a variant of the addStringField() method that accepts an echo character?
--
        -jeffB (Jeff Brandenburg, Duke Center for In-Vivo Microscopy)



<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
web.pylons.gene...    hurd.l4/2002-10...    kernel.commits....    user-groups.lin...    yellowdog.gener...    java.drools.use...    security.openva...    package-managem...    linux.debian.us...    qnx.openqnx.dev...    genealogy.gramp...    file-systems.if...    voip.wengophone...    tex.context/200...    ietf.smime/2003...    audio.csound.de...    culture.region....    xfree86.devel/2...    mobile.kannel.u...    distributed.con...    education.engli...    org.user-groups...    bug-tracking.gn...    recreation.bicy...   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe