Hello,
I have 2 classes one is the application and the other one the login
screen, when i start the application i create a JFrame with the login
screen. My login screen checks the username and password in a mysql db
and when correct it returns the userID to the application (because the
application needs to know this). This al works with the following
code :
in the login screen class 'Login' i have the code
[code]
Agenda ag = new Agenda();
...
if(userOK){
System.out.println("userOK gets executed."); //to check if the
credentials where ok
jLabel1.setBackground(Color.green);
jLabel1.setText("You can enter"); //jLabel1 on the login
screen itself
System.out.printf("userid %d\n",userID); //to check the value of the
userID (this works)
ag.setUserID(userID); //method in the application class
'Agenda' to set the userID there
}
[/code]
in the application class 'Agenda' i have the setUserID method:
[code]
public void setUserID(int uID){
System.out.println("setUserID"); //to check if the method gets
called = ok
userIDapp=uID;
System.out.printf("userid %d\n",userIDapp);//to check if the uID
argument gets assigned to the locale variable userIDapp = ok
jLabel2.setText(""+ userID); //when i try to set the text of
jLabel2 a JLabel in the 'Agenda' class i get an error also when i just
put jLabel2.setText("test");
}
[/code]
the error:
Exception in thread "AWT-EventQueue-1" java.lang.NullPointerException
at agenda.Agenda.setUserID(Agenda.java:93)
line 93 =
[code]
jLabel2.setText(""+ userID);
[/code]
I'm still learning so if i make big mistakes here forgive me and teach
me better ways
thanks
Marco
--
You received this message because you are subscribed to the Google Groups "The
Java Posse" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/javaposse?hl=en.