1

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)

Alex D Rex
  • 89
  • 1
  • 9
  • 4
    Possible 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 Answers1

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