1import java.awt.Color;
2import java.awt.Graphics;
3
4import javax.swing.JApplet;
5import javax.swing.JPanel;
6
7public class SwingHelloWorld2 extends JApplet {
8 public void init() {
9 JPanel p = new MyPannel();
10 add(p);
11 }
12}
13
14class MyPannel extends JPanel {
15 public void paintComponent( Graphics g ) {
16 setBackground( Color.blue );
17 setForeground( Color.yellow );
18 super.paintComponent(g);
19 g.drawString( "Hello World!", 25, 25 );
20 }
21}