This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Applets and the fly likes Applet doesn't repaint properly Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Applets
Bookmark "Applet doesn Watch "Applet doesn New topic
Author

Applet doesn't repaint properly

Steve O Smith
Greenhorn

Joined: Aug 19, 2010
Posts: 8
This applet doesn't repaint properly after it's minimized or another window gets on top of it.




Don't I need a repaint or update method here?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42375
    
  64
You shouldn't use the paint method with Swing, but the paintComponent method; paint is for AWT components.


Ping & DNS - my free Android networking tools app
Steve O Smith
Greenhorn

Joined: Aug 19, 2010
Posts: 8
Wow. That's the method used in the textbook for my intro to compsci class. The examples in the book have the same problem.

Didn't the author think to, oh I don't know, google this or ask on a forum? Jeez.

Thanks. I'll look into paintcomponent().
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4642
    
    5

JApplet doesn't have a paintComponent(...) method. Custom painting in Swing is best done in an extended JComponent or JPanel, by overriding the paintComponent(...) method mentioned by Ulf. More here: Lesson: Performing Custom Painting.


luck, db
There are no new questions, but there may be new answers.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Applet doesn't repaint properly