File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Removing graphical trash from JLayeredPane

 
Andrew Ryaskov
Greenhorn
Posts: 1
C++ Java Linux
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everybody!
Help me to remove this graphical artifact from JLayeredPane:

There is a simple app with drawing panel(Scene) inherited from JLayeredPane and graphical objects on it - inherited from JComponent with overridden paintComponent():

If zoom == 1.0 ( g.scale(1.0, 1.0) in Scene's paint() method ) it's OK - moving objects in scene dont lead to graphical artifacts:


But if I set zoom greater or lower than 1.0, I've got some bugs while moving objects by mouse:


How to remove this "trace"?

Thank you!



 
Rob Camick
Ranch Hand
Posts: 2475
8
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A JComponent doesn't repaint its background. So I'm guessing you need to add code to do this in the paintComponent() method. Something like:

 
Rob Spoor
Sheriff
Pie
Posts: 20393
46
Chrome Eclipse IDE Java Windows
  • 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Or extend JPanel instead of JComponent; don't forget to call super.paintComponent(g) as the first statement in the overridden paintComponent method, or you'll get the same result.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic