aspose file tools*
The moose likes Applets and the fly likes Applet initial painting - content overlap? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Applets
Bookmark "Applet initial painting - content overlap?" Watch "Applet initial painting - content overlap?" New topic
Author

Applet initial painting - content overlap?

Rob Hunter
Ranch Hand

Joined: Apr 09, 2002
Posts: 819
I have 4 small applets on a page that simply prints out the quadratic equation for values passed in. There are 4 applets on a page that have different values assigned. They display fine.... sometimes.... if I refresh or generate new numbers sometimes one applet looks as though it has numbers overlapping the new values. If I resize or drag the browser everything displays fine again - no need to refresh the browser or anything. It's as though old values or something are being overwritten by the new or something similar is happening. What should I include in the paint method of the JPanel that might help clear the applet before initial painting happens..... if anything? Thanks.
Tony Docherty
Bartender

Joined: Aug 07, 2007
Posts: 2286
    
  49
Without seeing your code I can only guess what you are doing.

First of all you shouldn't be overriding the paint() method, you should be overriding the paintComponent() method instead. This won't solve your current problem but it is the correct way to paint on swing components and it may well prevent other problems arising so rename your paint() method to the paintComponent().

If your panel is not being cleared properly starting the paintComponent() method with super.paintComponent() may well solve your problem.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Applet initial painting - content overlap?