aspose file tools*
The moose likes Applets and the fly likes update() method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Applets
Bookmark "update() method" Watch "update() method" New topic
Author

update() method

Gotham Sewani
Greenhorn

Joined: Feb 16, 2007
Posts: 15
I've just started with applets,and I was reading bout the init(),start(),paint(),stop(),destroy() and update() methods. I read that whenever a part of the appletwindow has to be redrawn:
1. The update() method is called. (BTW is this correct?)
2. The default implmentation of update method sets the the default background color and calls the paint method. (Is this correct?)

If we take the above two points to be correct,then if I override the update method such that it doesnt call the paint method,then will the paint method never be called. (Except maybe at the startup?).
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39548
    
  27
#1 - That's correct.

#2 - The default implementation of update calls paint, and the default implementation of paint does nothing - so no setting of the background color.

your last question - that's correct, too.


Ping & DNS - updated with new look and Ping home screen widget
Gotham Sewani
Greenhorn

Joined: Feb 16, 2007
Posts: 15
Then why does the following code print "In Paint" to the console whenever I minimize and maximize the window? :
import java.awt.*;
import java.applet.*;
/*
<applet code=PaintTest width=100 height=100>
</applet>
*/
public class PaintTest extends Applet {

public void paint(Graphics g) {
System.out.println("In paint");
}


public void update(Graphics g) {
System.out.println("In update");
}

}
Gotham Sewani
Greenhorn

Joined: Feb 16, 2007
Posts: 15
no replies?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: update() method
 
Similar Threads
threads
extends Canvas
repaint()
Applet wont load...
Flickering in JApplet