以下代码是用于登录和密码的弹出窗口(JOptionPane)。我怎样才能让我的Java程序记住这两个字符串:log
这样pass
当用户关闭程序并下次打开它时......上次插入的log
和插入的默认情况下已经存在?pass
import javax.swing.*;
public class TestJP {
public static String log;
public static String pass;
public static void main(String[] args) {
JTextField login = new JTextField(5);
JPasswordField password = new JPasswordField(5);
JPanel myPanel = new JPanel();
myPanel.add(new JLabel("login:"));
myPanel.add(login);
myPanel.add(Box.createHorizontalStrut(15));
myPanel.add(new JLabel("password:"));
myPanel.add(password);
int result = JOptionPane.showConfirmDialog(null, myPanel,
"Please Login", JOptionPane.OK_CANCEL_OPTION);
if (result == JOptionPane.OK_OPTION) {
log = login.getText();
pass = password.getText();
System.out.println("login: " + log);
System.out.println("password: " + pass);
}
}
}