import javax.swing.*;
import java.awt.event.*;
public class swing2 extends JFrame {
public swing2() {
super("titre de l'application");
WindowListener l = new WindowAdapter() {
public void windowClosing(WindowEvent e){
System.exit(0);
}
};
addWindowListener(l);
JButton bouton = new JButton("Mon bouton");
JPanel panneau = new JPanel();
panneau.add(bouton);
setContentPane(panneau);
setSize(200,100);
setVisible(true);
}
public static void main(String [] args){
JFrame frame = new swing2();
}
}