Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JPanel repainting weirdly

 
Thomas Moul
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1535
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Code adapted from reply 3 in this thread.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic