Search:

Type: Posts; User: Norm

Search: Search took 0.12 seconds.

  1. Replies
    60
    Views
    9,984

    Re: Tower Defense on Java

    I've never seen anything that simple.
  2. Replies
    60
    Views
    9,984

    Re: Tower Defense on Java

    Yes that describes inheritance.
  3. Replies
    60
    Views
    9,984

    Re: Tower Defense on Java

    You often need to print out objects to see what is in them.
  4. Replies
    60
    Views
    9,984

    Re: Tower Defense on Java

    Did you look at the contents of the Event object?
  5. Replies
    60
    Views
    9,984

    Re: Tower Defense on Java

    I printed the value of the e object passed to the listener methods.


    Because your if tests are not true.
  6. Replies
    60
    Views
    9,984

    Re: Tower Defense on Java

    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...
  7. Replies
    60
    Views
    9,984

    Re: Tower Defense on Java

    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:
  8. Replies
    60
    Views
    9,984

    Re: Tower Defense on Java

    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....
  9. Replies
    60
    Views
    9,984

    Re: Tower Defense on Java

    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.
  10. Replies
    60
    Views
    9,984

    Re: Tower Defense on Java

    See you later.
  11. Replies
    60
    Views
    9,984

    Re: Tower Defense on Java

    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.
  12. Replies
    60
    Views
    9,984

    Re: Tower Defense on Java

    Are the files being used by other versions of your program?
  13. Replies
    60
    Views
    9,984

    Re: Tower Defense on Java

    then your code here is wrong if a JPanel triggered the event, not a JLabel.
  14. Replies
    60
    Views
    9,984

    Re: Tower Defense on Java

    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...
  15. Replies
    60
    Views
    9,984

    Re: Tower Defense on Java

    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...
  16. Replies
    60
    Views
    9,984

    Re: Tower Defense on Java

    String ref1 = "The string";
    String ref2 = ref1; // now there are two references to "The String"
    String ref3 = ref2; // now 3
  17. Replies
    60
    Views
    9,984

    Re: Tower Defense on Java

    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()...
  18. Replies
    60
    Views
    9,984

    Re: Tower Defense on Java

    What class is the getComponent() method in? What does it do?
  19. Replies
    60
    Views
    9,984

    Re: Tower Defense on Java

    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.
  20. Replies
    60
    Views
    9,984

    Re: Tower Defense on Java

    Sometimes taking a short break from design work to try a few simple techniques will free up/relax the brain.
  21. Replies
    60
    Views
    9,984

    Re: Tower Defense on Java

    It the variables have unique names, that should work. Have you tried writing a small set of classes to test what happens?
  22. Replies
    60
    Views
    9,984

    Re: Tower Defense on Java

    The Timer calls your code. Your code will have lists (in arrays or ArrayLists) of what is to be updated.
  23. Replies
    60
    Views
    9,984

    Re: Tower Defense on Java

    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...
  24. Replies
    60
    Views
    9,984

    Re: Tower Defense on Java

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