I was experimenting with JOptionPane in Java and I want to make a simple password program. Upon creating it, I wanted to implement a password autosave function. I do not know the method that actually accesses the text box (the area where you enter text).
import javax.swing.JOptionPane;
public class passWord_GUI {
public static void main(String[] args) {
String username = JOptionPane.showInputDialog("Enter username");
String password = JOptionPane.showInputDialog("Enter password");
//password.setTheConentOfTheTextBox(passwordSave);
//Set up the UI.
if (username != null
&& password != null
&& username.equals("asdf")
&& password.equals("swordfish")) {
JOptionPane.showMessageDialog(null, "You're in!");
String passwordSave = "swordfish";
} else {
JOptionPane.showInternalMessageDialog(null, "Wrong! Try again.");
}
}
}
I just want to know a way to edit the contents of the text box without having to actually type something in it. In this case, write a password.
You're help is appreciated!