Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Custom Password Dialog

 
Brian Podolny
Ranch Hand
Posts: 32
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm trying to write a class that is a custom JDialog. It has a JTextField for a Username, JPasswordField, and then a third JTextField which is labled in the constructor. The purpose of the dialog is to enable users to log on to a domain, database, etc. I included a getInput method which returns an array of Strings with the inputs.
How can I get the parent frame to grab the string array from the JDialog? Also, what code do I need to write to close the JDialog? I've worked with frames and know how to write a WindowListener for the closing, but how can I make the window close itself when the user clicks on an "enter" button( in the JDialog ) and still get the parent app to grab the information.
Thanks for whatever help you can give me.
 
Thomas Paul
mister krabs
Ranch Hand
Posts: 13974
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Add a public method to the dialog which returns the array:
public String[] getLoginInformation() {
return loginInformation;
}
 
Brian Podolny
Ranch Hand
Posts: 32
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the response Thomas. What I mean is, how can I register an actionListener such that when a button is pressed on the Jdialog, it passes the string[], and then the JDialog is closed and destroyed. I've already included a getInput method( the same as what you mentioned above) in the JDialog that returns the String[].
I guess I could just register an ActionListener with a button that sets the String[] in the parent class, but I still don't know how to force the closing of the JDialog.

[This message has been edited by Brian Podolny (edited October 13, 2000).]
 
Thomas Paul
mister krabs
Ranch Hand
Posts: 13974
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
call the JDialog's dispose() method. (Inherited from awt.dialog)
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic