File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
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.
It is sorta covered in the JavaRanch Style Guide.
subject: JPanel repainting weirdly
Similar Threads
Help on Applet idea
Do certain events make calls to repaint redundant?
watching an applet to draw waveform
Jpanels and Jscrollpanels
jpanel help