Search:

Type: Posts; User: Norm

Search: Search took 0.13 seconds.

  1. Thread: Java SnakeGame

    by Norm
    Replies
    35
    Views
    2,054

    Re: Java SnakeGame

    You need to set the component that has the listeners so that it can get the focus. The setFocusable method will do that.
  2. Thread: Java SnakeGame

    by Norm
    Replies
    35
    Views
    2,054

    Re: Java SnakeGame

    If you want help with error messages, you should copy the full text and paste it here.
  3. Thread: Java SnakeGame

    by Norm
    Replies
    35
    Views
    2,054

    Re: Java SnakeGame

    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...
  4. Thread: Java SnakeGame

    by Norm
    Replies
    35
    Views
    2,054

    Re: Java SnakeGame

    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...
  5. Thread: Java SnakeGame

    by Norm
    Replies
    35
    Views
    2,054

    Re: Java SnakeGame

    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.
    ...
  6. Thread: Java SnakeGame

    by Norm
    Replies
    35
    Views
    2,054

    Re: Java SnakeGame

    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...
  7. Thread: Java SnakeGame

    by Norm
    Replies
    35
    Views
    2,054

    Re: Java SnakeGame

    I need a source file for debugging. I do NOT download from other sites.
  8. Thread: Java SnakeGame

    by Norm
    Replies
    35
    Views
    2,054

    Re: Java SnakeGame

    I need a source for debugging.
  9. Thread: Java SnakeGame

    by Norm
    Replies
    35
    Views
    2,054

    Re: Java SnakeGame

    Can you Make a small, complete program that compiles, executes and shows the problem?
  10. Thread: Java SnakeGame

    by Norm
    Replies
    35
    Views
    2,054

    Re: Java SnakeGame

    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.
  11. Thread: Java SnakeGame

    by Norm
    Replies
    35
    Views
    2,054

    Re: Java SnakeGame

    See the tutorial: Lesson: Performing Custom Painting (The Java™ Tutorials > Creating a GUI With JFC/Swing)
  12. Thread: Java SnakeGame

    by Norm
    Replies
    35
    Views
    2,054

    Re: Java SnakeGame

    The draw() method should be called from the paint() method because that is where the Graphics object is.
  13. Thread: Java SnakeGame

    by Norm
    Replies
    35
    Views
    2,054

    Re: Java SnakeGame

    Does g have a null value? How is the draw() method called? Where is the args passed to draw() given a value?
  14. Thread: Java SnakeGame

    by Norm
    Replies
    35
    Views
    2,054

    Re: Java SnakeGame

    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...
  15. Thread: Java SnakeGame

    by Norm
    Replies
    35
    Views
    2,054

    Re: Java SnakeGame

    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.
  16. Thread: Java SnakeGame

    by Norm
    Replies
    35
    Views
    2,054

    Re: Java SnakeGame

    Please copy the full text of the error message and paste it here.
    Also post the new code that causes the error.
  17. Thread: Java SnakeGame

    by Norm
    Replies
    35
    Views
    2,054

    Re: Java SnakeGame

    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...
Results 1 to 17 of 17