You need to set the component that has the listeners so that it can get the focus. The setFocusable method will do that.
Type: Posts; User: Norm
You need to set the component that has the listeners so that it can get the focus. The setFocusable method will do that.
If you want help with error messages, you should copy the full text and paste it here.
Where are the println() statements? You need to leave them in to show me how you were using them for debugging.
There still is code in the paintComponent() method that should NOT be there. Move...
Please post the code on the forum, not as an attachment.
Is the key listener method being called? Did the println() you put in that method print anything?
Copy the full text of the print...
The code needs lots of debugging so you can see what it is doing when it executes. Try adding println() statements to the different methods to see where the code is executing or not executing.
...
Are those two files: a small, complete program that compiles, executes and shows the problem?
What is supposed to happen when the code is executed?
I get some green squares in the upper left...
I need a source file for debugging. I do NOT download from other sites.
I need a source for debugging.
Can you Make a small, complete program that compiles, executes and shows the problem?
Is the snake's x,y location being changed?
Make a small, complete program that compiles, executes and shows the problem. what is posted can't be used for testing.
See the tutorial: Lesson: Performing Custom Painting (The Java™ Tutorials > Creating a GUI With JFC/Swing)
The draw() method should be called from the paint() method because that is where the Graphics object is.
Does g have a null value? How is the draw() method called? Where is the args passed to draw() given a value?
The code STILL has the call to the method: GenerateDefaultSnake() INSIDE of the paint() method.
Code that is used one time to initialize variables should NOT be in the paint() method.
Move the call...
It can't be if you changed the program.
If you didn't change the program, nothing will change and it will be the same.
Please copy the full text of the error message and paste it here.
Also post the new code that causes the error.
The paint() method is NOT a good place to initialize variables. paint() can be called for various reasons at different ttimes.
If the variable should be initialized one time, it better to do it in...