On Wed, 2002-01-23 at 02:58, Bob Tanner wrote:
> Is it just me or are inner-anonymous classes just hard to read?
Inner-anonymous classes can be hard to read. But you avoid having an
extra source file that simply overrides one method on Authenticator.
Creating the class in-line lets you leave the source where it makes the
most sense and avoid having misc. classes clog your project.
>
> I believe this is an inner-anonymous class?
>
> public PasswordAuthentication
> getPasswordAuthentication() {
> String username, password;
>
> String result = JOptionPane.showInputDialog("Enter 'username,password'");
>
> StringTokenizer st = new StringTokenizer(result, ",");
> username = st.nextToken();
> password = st.nextToken();
>
> return new PasswordAuthentication(username, password);
> }
>
Correct code would look like this:
Authenticator objAuthenticator = new Authenticator(){
//Insert above code here
}
This produces an object of type Authenticator that has the method
getPasswordAuthentication() overridden.
--
David Hadley
http://www.applisaurus.com/