I must compare a data entered by the jtextfiel
with the data that is a file txt
and when comparing it it says:
Incompatible operand types string and JTextField
The data I want to compare is the username and password:
public int leerficheroo(){
String fichero = "C:/Usuario.txt";
try {
FileReader fr = new FileReader(fichero);
BufferedReader br = new BufferedReader(fr);
String linea;
while((linea = br.readLine()) != null) {
String[] lineaArreglo = linea.split(";");
String usuario=lineaArreglo[1];
String contrasena=lineaArreglo[2];
if(usuario.equals(ventana1.user) && contrasena.equals(ventana1.pass))
{
return 1;
}
else
return 2;
}
the error comes up in the (if) when asking if the data of the txt is equal to the one of the jtextfiel that is in another class in which it tries to change the type of data so
public static JTextField txtUsuario;
public static JPasswordField passUsuario;
static String user = txtUsuario.getText();
static String pass = passUsuario.getText();