Jump to content

Java beginner - Problem with Graphic not Repainting


Recommended Posts

I've spent the last week trying to get an application to work in Java.

The ultimate goal of what I'm working on now is a fountain, which produces numerous water drops which rise off the top of the canvas.

What I would like the erroneous code do is make each water drop in the fountain rise by two pixels. If its y position gets equal or below 0 then the timer should stop.

The timer works, it decreases in the interval I have specified, but trying to redraw the water droplet fails.

I am beginning to think that I need to use the repaint method of what I have called the "Display" class to repaint all items to make the canvas update. The only issue with this is that is that the water drop objects cannot call the class method repaint (in Display). The timers are a part of each water drop so I've presumed they should be in the water drop object.

If someone could look at the attached Java files and explain what part of the implementation is flawed it would be a great help.

Not_Repainting.zip

Edited by BrainDrain
Link to comment
Share on other sites


Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...