Skip to content
View in the app

A better way to browse. Learn more.

MSFN

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Java beginner - Problem with Graphic not Repainting

Featured Replies

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

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.