Meaningless Drivel is fun!
The moose likes Swing / AWT / SWT and the fly likes JPanel repainting weirdly Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JPanel repainting weirdly" Watch "JPanel repainting weirdly" New topic

JPanel repainting weirdly

Thomas Moul

Joined: Sep 17, 2004
Posts: 4
In my program I have a JPanel that contains a picture of a waveform in a JFrame. That part is fine. But I also made it so that if you click on it and drag it will scroll through the waveform, which does scroll, but doesn't repaint correctly. It causes the about half the picture to appear below the actual picture. It's not a huge problem, but it's really annoying, and I haven't found a way to fix it yet.

Currently I have a MouseInputListener in the JPanel checking to see if it is dragged, and then resetting what data was part of the waveform, and finally calling repaint(). Maybe repaint isn't the best? Thanks for any help.
Craig Wood
Ranch Hand

Joined: Jan 14, 2004
Posts: 1535
Code adapted from reply 3 in this thread.
I agree. Here's the link:
subject: JPanel repainting weirdly
It's not a secret anymore!