KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > HelloSwingApplet


1 import javax.swing.*;
2 import java.awt.*;
3
4 public class HelloSwingApplet extends JApplet
5 {
6     
7     // This is a hack to avoid an ugly error message in 1.1.
8
public HelloSwingApplet()
9     {
10         getRootPane().putClientProperty("defeatSystemEventQueueCheck", Boolean.TRUE);
11     }
12     
13     public void init()
14     {
15         JLabel label = new JLabel("You are successfully running a Swing applet!");
16         label.setHorizontalAlignment(JLabel.CENTER);
17         
18         //Add border. Should use createLineBorder, but then the bottom
19
//and left lines don't appear -- seems to be an off-by-one error.
20
label.setBorder(BorderFactory.createMatteBorder(1, 1, 2, 2, Color.black));
21         
22         getContentPane().add(label, BorderLayout.CENTER);
23     }
24     
25 }
26
Popular Tags