• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Applet does not getting repainted when covered portion gets uncovered

 
Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 105
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Isn't there anybody to help me?
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 105
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 105
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Mr. Dittmer, you are the best! Thank you very much! :-)
 
reply
    Bookmark Topic Watch Topic
  • New Topic