1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
| package test;
//import java.awt.event.*;
//import java.applet.*;
import java.awt.*;
import javax.swing.*;
public class MonApplet extends JApplet{
private static final long serialVersionUID = -4346432255634031396L;
public void init() {
try {
javax.swing.SwingUtilities.invokeAndWait(new Runnable(){
public void run(){
createGUI();
}
});
} catch (Exception e){
System.out.print("ça plante...");
}
}
private void createGUI() {
JLabel label = new JLabel("Hello World");
label.setHorizontalAlignment(JLabel.CENTER);
label.setBorder(BorderFactory.createMatteBorder(1, 1, 1, 1, Color.black));
getContentPane().add(label, BorderLayout.CENTER);
}
} |