I just subscribed to this forum as numerous threads on here have already helped me with my simple Java programs.
I am a Technical Computing student and have recently started to learn about and program in the Java language.
For my project I need to make a Java GUI with Netbeans which will interact with a MySQL database using JDBC.
So far so good, but I want to make a separate class CheckLogin.java which will check if the login information is the same as in the database.
I want to make the constructor of this class set a text in a textfield of the main login form (Login.java) on error.
Something like statusTextField.setText("Login not correct."). Since this textfield is declared private in the source code and I cannot change this in the Netbeans builder, I thought of writing a method in the Login.java which would do this for me.
Method in Login.java:
public static void setStatus(String status) {
statusTextField.setText(status);
}
Now, when I try to use the
Login.setStatus("Login not correct")
of the CheckLogin.class I get an error in the Login.java class saying:"non-static variable statusTextField cannot be referenced from a static context"
If I remove the static from the setStatus method I get the same error in the CheckLogin.java about setStatus(lang.java.String).
I have searched pages and pages of google but I cannot find the solution for this or figure out where this is coming from with my limited programming experience. I hope someone can point me in the right direction.
Thanks in advance.

New Topic/Question
Reply




MultiQuote



|