I am a novice Java coder. And I am having trouble finding the problem when I start up the program and click the "list files" button, and there are more than 37 files or more to load. It crashes and gives me a null pointer exception at line 77 in the Displays class. Any help would be greatly apreciated. I am still in the process of writing it. So any half finished code is supposed to be that way.

nobody will bothered to download your sources, or is behind a firewall and cannot access it. Post a SSCCE.

April 23rd, 2013, 06:13 AM

Norm

Re: Java Program Help

Quote:

gives me a null pointer exception at line 77

There is a variable with a null value on line 77. Look at line 77 in the your source and see what variable is null. Then backtrack in the code to see why that variable does not have a valid value.
If you can not tell which variable it is, add a println just before line 77 and print out the values of all the variables on that line.

There is a variable with a null value on line 77. Look at line 77 in the your source and see what variable is null. Then backtrack in the code to see why that variable does not have a valid value.
If you can not tell which variable it is, add a println just before line 77 and print out the values of all the variables on that line.

I am adding a panel from an array of panels to a frame and says null pointer exception.

frame.add(panel[0]);

and at this line it says null pointer exception. I even checked to see if the panel array wasn't initialized correctly. But the length is 2 so I know it was initialized correctly. But it still doesn't work.

April 23rd, 2013, 08:17 PM

Norm

Re: Java Program Help

What are the values of frame and panel[0]?

The slots in an array of objects are initially null.

April 23rd, 2013, 10:20 PM

buttcrackbil

Re: Java Program Help

*facepalm* Something as simple as initializing the points in an array stopped me. Thank you.