Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

repaint

 
saravanan ragunathan
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


i herad that when we cover appletviewer by another window and uncovers it,method repaintwill be called,
but in my program when i cover the appletviewer by another window the Line has been drawn was erased..
then i inserted the statement in paint method System.out.println("paint"); to check whether the thread invokes paint method
but it didn't invoke...could any one help me to recover this problem.
 
Kevin Workman
Ranch Hand
Posts: 151
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you want help, you should provide an SSCCE that demonstrates the problem.
 
Lester Burnham
Rancher
Posts: 1337
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you're using Swing then generally you shouldn't be using paint, but rather paintComponent. See http://java.sun.com/products/jfc/tsc/articles/painting/#callbacks
 
Kevin Workman
Ranch Hand
Posts: 151
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Lester Burnham wrote:If you're using Swing then generally you shouldn't be using paint, but rather paintComponent. See http://java.sun.com/products/jfc/tsc/articles/painting/#callbacks


I agree that you should be using paintComponent, but it also means that you need to override JPanel (or JComponent) to do so. JApplet, what you're extending now, does not have a paintComponent method. So what you want to do is extend JPanel (or JComponent), override paintComponent, then set that as the JApplet's content pane.

Or you could, you know, post that SSCCE that demonstrates what you're trying to do. Up to you.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic