I've never seen anything that simple.
Type: Posts; User: Norm
I've never seen anything that simple.
Yes that describes inheritance.
You often need to print out objects to see what is in them.
Did you look at the contents of the Event object?
I printed the value of the e object passed to the listener methods.
Because your if tests are not true.
What the printlns will tell you is if the listeners are being called. They are.
So now you need to look at the event object data and see how you can detect the keys you want to handle in the...
Where is the printlns I suggested you add to the listener methods to see if they are being called?
When I added some I got this:
I use printlns for debugging. When I don't know what a program is doing I add printlns so I can see what is happening.
No. I want a small program that has just enough in it to show the problem....
Your code doesn't have an printlns to show you what is happening.
Please make a small simple complete program (SSCCE) that compiles and executes and shows your problem and post it here.
See you later.
If parts of your program are using a file,then you will not be able to delete it.
You need to close the file when the code is finished using it.
Are the files being used by other versions of your program?
then your code here is wrong if a JPanel triggered the event, not a JLabel.
Some where in you GUI there is a JLabel component. It is possible to have dozens of different variables that refer to that one JLabel object. The getComponent() method gives you one of the many...
Your code does not show what the values of ref1 and ref3 are. You only show that ref2's value is changed to refer to the String "Cake"
If you are using the variables from my example, their values...
String ref1 = "The string";
String ref2 = ref1; // now there are two references to "The String"
String ref3 = ref2; // now 3
The API doc: returns the Component object that originated the event, or null if the object is not a Component.
What event are you going to create that you would want to tailor its getComponent()...
What class is the getComponent() method in? What does it do?
How are the Tower objects drawn on the GUI? Can you use the same logic with the mouse listener to tell the objects that the mouse is over them.
Sometimes taking a short break from design work to try a few simple techniques will free up/relax the brain.
It the variables have unique names, that should work. Have you tried writing a small set of classes to test what happens?
The Timer calls your code. Your code will have lists (in arrays or ArrayLists) of what is to be updated.
Up to a limit. You do not want too many threads.
You could use a Timer to start a thread that could quickly update the positons and status of many objects before calling repaint to have the paint...
Threads allow your code to do more that one thing at almost the same time.
The code that executes on one thread can be doing something while the code that executes on a different thread can be doing...