• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Applet does not getting repainted when covered portion gets uncovered

 
Prosenjit Banerjee
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have written all the drawing codes in the paint method of my applet. The applet gets redrawn whenever it is resized. But when a covered portion of it gets revealed, it does not getting redrawn. Please tell me what to do. The applet looks like as follows:
 
Prosenjit Banerjee
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Isn't there anybody to help me?
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JComponent and its children do not use paint(Graphics) to draw themselves but paintComponent(Graphics). See if that solves the issue. Also, remove the call to super.paint.
 
Prosenjit Banerjee
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JavaDocs shows that the hieracrhy



No class in this hierarchy contains the methond paintComponent(). The method resides in JComponent class which not a part of this hierarchy. Then, how can I override this method? Nothing is displayed if I write a paintCompnent(Graphics) method. Please help.
[ January 26, 2008: Message edited by: Prosenjit Banerjee ]
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're quite right that JComponent isn't in that hierarchy, and that you can't override paintComponent in the JApplet code. I should have been more elaborate.

This is what the javadocs of JApplet mean by briefly mentioning that JApplet is slightly incompatible with Applet. You'd do the drawing in some component (like a JPanel) which then gets added to the applet via applet.getRootPane().add(JPanel).
 
Prosenjit Banerjee
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mr. Dittmer, you are the best! Thank you very much! :-)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic