public class Graph extends Applet {
static final String message = "Hello World";
private Font font;
// one time initialization of the the applet
public void init(){
font = new Font("Helvetica",Font.BOLD, 48);
}
...
public class HelloWorld extends Applet {
public void paint(Graphics g) {
g.drawString("Hello world!", 50, 25);
}
}
public class HelloWorld extends Applet {
public void paint(Graphics g) {
g.drawString("Hello world!", 50, 25);
}
}
public void init() {
...
this.add(new Label("Color: "));
...
}
The add function makes it so the applet will tell the Label to draw itself
upon a refresh.
public class Scribble extends Applet {
private Button clear_button; // The clear button.
// This method is called when the user clicks the button or chooses a color.
public boolean action(Event event, Object arg) {
// If the Clear button was clicked on, handle it.
if (event.target == clear_button) {
// code to handle button push
return true;
}
return fals;
}
}
public boolean mouseDown(Event event, int x, int y) {
// the subtractions are because the upper left
// corner of the gif is put on the catx and caty
catx = x-50;
caty = y-50;
repaint();
return true;
}