I have a problem with getting an input from class A to class B. I already created a method which gets the value but when I call it in class b it returns empty.
These are my codes:
CLASS A
public class log extends javax.swing.JFrame {
public String name;
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
System.out.println("1"+getuser());
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/devweb", "root", "123456");
PreparedStatement statement = con.prepareStatement("select User,pwd from account");
ResultSet rs = statement.executeQuery();
name = user.getText();
String pwd = jTextField2.getText();
while (rs.next()) {
if (rs.getString("User").equals(name) && rs.getString("pwd").equals(pwd)) {
user.getText();
result now = new result();
getuser();
now.res();
now.jTextField1.setText(name);
System.out.println("2"+getuser());
}
}
} catch (Exception e) {
System.out.println(e.getMessage());
}
}
public String getuser() {
return this.user.getText();
}
CLASS B(I'm gonna post the button straight away since that this is the only thing that this class contains)
private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {
log qwe=new log();
qwe.getuser();
jTextField1.setText(qwe.user.getText());
System.out.println("3"+qwe.getuser());
System.out.println("5"+qwe.user.getText());