Welcome to Kodlogs Q&A, where you can ask programming questions and receive answers from other members of the community. For programmers, by programmers Kodlogs is an open community for anyone that does coding. We help you get answers to your toughest coding questions, share knowledge with your coworkers in private, and find your next IT dream job.
0 votes
6 views
exception in thread "awt-eventqueue-0" java.lang.nullpointerexception
in Java Programming by (2.5k points)

1 Answer

0 votes
The variable num is invalid, and until you relegate a non-invalid an incentive to it will stay invalid. Presently there are two conceivable fixes:

1) appoint a non-invalid an incentive to num in its constructor

2) check against invalid in paintComponent:

?

super.paintComponent(page);

in the event that (num != invalid)

{

page.drawLine(50,50,50+num.real,50+num.imag);

}
by (8.5k points)
...