public class HelloApplet2
1: //HelloApplet2.java
2: //An applet to display "Hello, world!" in a browser window.
4: //<applet code="HelloApplet2.class"
5: // width="800"
6: // height="300">
7: //</applet>
9: import java.awt.*;
10: import java.applet.*;
12: public class HelloApplet2
13: extends Applet
14: {
15: //The paint method is automatically called by a browser.
16: //Here we override paint() method to automatically display
17: //information in the applet's window. The paint method
18: //is called automatically to display the graphics object.
19: public void paint(Graphics g)
20: {
21: //Declare the font you want:
22: Font font = new Font("Serif", Font.BOLD, 72);
24: //Set font and color, and then display message
25: //on the screen at position (175, 150):
26: g.setFont(font);
27: g.setColor(Color.red);
28: g.drawString("Hello, world!", 175, 150);
29: }
30: }