Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JScrollPane and paint

 
Bigwood Liu
Ranch Hand
Posts: 240
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am trying to paint something on a JPanel, I extends the Jpanel and overrided the paint() method in it, then put the MyJpanel into a JScrollPane.
But when I dragged the scroll bar, the drawing in JPanel is blured. That is no repainting, how to solve it? Thanks.
Best,
Damu
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24204
34
Chrome Eclipse IDE Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Swing components are a bit different than AWT ones. Instead of overriding paint(), override paintComponent(Graphics) instead.
 
Bigwood Liu
Ranch Hand
Posts: 240
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, thank you, I tried but no improve.
I tried paintChildren, it works ?
[ January 19, 2004: Message edited by: damu liu ]
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You shouldn't override paintChildren(), or you won't be able to see any components that are added to your panel. When you override paintComponent( Graphics g ) the first line should be -


Then do your custom painting.
 
Bigwood Liu
Ranch Hand
Posts: 240
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Nathan,
Thank you, I followed yuor suggestion, it works perfect!
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic