I have made a program that starts with a log in form. I want to put the option to change the password and the username, but after closing the program and when I open it again these variables get the default value. This is the code of changing class where username is a global variable named "emriuser" and password is "fkalimi" , I made them global to use in different classes on my project and I don't know, it is the right way? Therefore I want to know how to store their value after closing the program:
public class Change extends javax.swing.JFrame {
// .......
private void oActionPerformed(java.awt.event.ActionEvent evt) {
String p = pass2.getText();
String u = uiri.getText();
if (u.equals(emriuser) && (p.equals(fkalimi))){
emriuser=u;
fkalimi=p;
// here a code how to store the values
}
Also I want to know how to call their value when I open next time the program:
public class LogIn extends javax.swing.JFrame {
// .......
/**
* here the code I dont know
.........
and then is the code I wrote to be executed if the pass and username haven't change
*/
emriuser="user1";
fkalimi="DThShI=0I";
String p1 = pass1.getText();
String u1 = uname1.getText();
if (u1.equals(emriuser) && (p1.equals(fkalimi))){
setVisible(false);
f1 a=new f1 ();
a.setTitle("Main Menu");
a.pack();
a.show();
}
Can Someone help me please, thanks in advance!