Java Example Program / Sample Source Code
import java.awt.*;
import java.applet.*;
public class AppletUsingCanvas extends Applet {
public void init() {
CanvasExample canvas = new CanvasExample();
add(canvas);
}
}
class CanvasExample extends Canvas {
public CanvasExample() {
setSize(120, 50);
}
public void paint(Graphics g) {
g.drawRect(0, 0, 119, 49); // draw border
g.drawString("Canvas Example", 20, 20);
}
} |
|
|