Java Example
Next, the source of the demo.java file is shown.
import java.applet.*;
import java.awt.*;
public class Demo extends Applet {
Image image;
int count;
public void init() {
image = getImage(getDocumentBase(), "world.jpg");
count = 1;
}
public void paint(Graphics g) {
g.drawImage(image, 0, 0, this);
g.setColor(Color.red);
for (int y = 15; y < size().height; y += 15) {
int x = (int) (size().width/2 + 30*Math.cos(Math.PI*y/75));
g.drawString("Hello", x, y);
}
showStatus("Paint called "+count+" time"+((count > 1)?"s":""));
count += 1;
}
}
You can get the source here
and the world.jpg image here.
|