I have created a login form and a clock, i have set the clock to run on jlabel and when i try to run the program it gives me an error saying, Exception in thread "Thread-1" java.lang.NullPointerException at project.jf_login_form$2.run(jf_login_form.java:125)
Asked
Active
Viewed 58 times
1
-
4Possible duplicate of [What is a NullPointerException, and how do I fix it?](http://stackoverflow.com/questions/218384/what-is-a-nullpointerexception-and-how-do-i-fix-it) – Timothy Truckle Jan 02 '17 at 10:10
1 Answers
2
You first call call()
and then JL_clock = new JLabel("hello");
So you first call JL_clock.setText("Time "+hour+":"+minuite+":"+second+" Date "+day+"/"+month+"/"+year);
before initializing the object.
Possible solution:
clock();
JL_username = new JLabel("Username:");
JL_pass = new JLabel("Password:");
JL_clock = new JLabel("hello");
Should be replaced with
JL_username = new JLabel("Username:");
JL_pass = new JLabel("Password:");
JL_clock = new JLabel("hello");
clock();

xenteros
- 15,586
- 12
- 56
- 91