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 31 32 33 34 35
| package premiereFenetre;
import javax.swing.*;
public class SimpleFenetre extends JFrame implements java.io.Serializable{
/**
*
*/
private static final long serialVersionUID = -7356083746040031008L;
public SimpleFenetre(){
super();
build();//On initialise notre fenêtre
}
private void build(){
this.setTitle("Ma première application"); //On donne un titre à l'application
this.setSize(320,320); //On donne une taille à notre fenêtre
this.setLocationRelativeTo(null); //On centre la fenêtre sur l'écran
this.setResizable(true) ; //On interdit la redimensionnement de la fenêtre
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //On dit à l'application de se fermer
//lors du clic sur la croix
}
public static void main(String[] args){
SwingUtilities.invokeLater(new Runnable(){
public void run(){
//On crée une nouvelle instance de notre fenêtre
SimpleFenetre gui = new SimpleFenetre();
gui.setVisible(true);//On la rend visible
}
});
}
}//fin de class SimpleFenetre |
Partager