hrm - but my reply didn't answer your question did it - I don't think this
is an anonymous inner class, or if it was supposed to be, was not done
properly - in that it calls a constructor for a named class, and don't
provide any anonymous class definition...
On Wed, 23 Jan 2002, Liz Burke-Scovill wrote:
>
> It looks like a function to me...
> On Wed, 23 Jan 2002, Bob Tanner wrote:
>
> > Is it just me or are inner-anonymous classes just hard to read?
> >
> > I believe this is an inner-anonymous class?
> if you move the first line around so that it's more commonly readable you
> get this - a public function called getPasswordAuthentication with a
> return object of class PasswordAuthentication (new instantiation of the
> class)- looks like a member function to me..without seeing the rest of the
> class , it looks a little thin to me, though...
>
> Liz
>
> public PasswordAuthentication getPasswordAuthentication() {
> String username, password;
>
> //prompt for user input
> String result = JOptionPane.showInputDialog("Enter 'username,password'");
>
> /* parse result into tokens for use in creating a new
> PasswordAuthentication object*/
>
> StringTokenizer st = new StringTokenizer(result, ",");
> username = st.nextToken();
> password = st.nextToken();
> //return object - useless by itself, but practical if it's being used
> // elsewhere
> return new PasswordAuthentication(username, password);
> }
>
> If I were to use code like this it would be to push it into a vector, or
> to otherwise use it - ie...
>
> // ...
> // PasswordAuthentication pa = getPasswordAuthentication();
> // ...
>
> However, I definitely wouldn't use it this way - and it might just break
> since it looks like username and password should be private fields -
> instead, considering this performs the function of a consturctor, I'd
> write the default constructor to prompt for the information.
>
> public class PasswordAuthentication {
> private String username = "";
> private String password = "";
>
> public PasswordAuthentication() {
> // not sure that the following will work either sicne I don't know
> // swing all that well, but using it to show the example.
>
> String result = JOptionPane.showInputDialog("Enter 'username,password'");
> StringTokenizer st = new StringTokenizer(result, ",");
> username = st.nextToken();
> password = st.nextToken();
> }
>
> public PasswordAuthentication(String usr, String pw) {
> username = usr;
> password = pw;
> }
>
> }
>
>
--
Imagination is intelligence having fun...
e-mail: kethry at winternet.com
URL: http://WWW.winternet.com/~kethry/index.html