Glad you got it working.
Type: Posts; User: Norm
Glad you got it working.
Is the key listener method called? Add a println() to see.
The code works for me.
New images should NOT be loaded in the paintComponent() method. Load the image outside of that method and then call repaint() to have the system call the paintComponent() method where the newly...
Change a and call repaint().
Set a to the first image in the constructor so its value is not null when paintComponent() is called.
You don't control when the system calls the paint methods. The repaint() method requests that a call be made some time (usually soon).
What do you want to see on the screen BEFORE the user presses...
The test for a being null would be in the paintComponent() method.
You can't change the order of when the methods are executed. The user's key pressed can't be recognized before the screen is...
The paintComponent() method is called BEFORE the user gets a chance to press any keys. Add code there to test if a is null before using the value in a.
There is a null value when line 48 is executed. Look at line 48, find the null value and then backtrack in the code to see where the null value came from.
When you have errors, you should copy the full text of the message and paste it here.
@jocdrew21 Please edit the code in your post and give it proper formatting. Nested statements should be indented.
@jerinjose61 Please edit your post and wrap your code with code tags:
YOUR...