public class FenSimple extends JFrame { public FenSimple(String titre, int x, int y, int w, int h){ super(titre); // this.setDefaultCloseOperation(EXIT_ON_CLOSE); this.setDefaultCloseOperation(DISPOSE_ON_CLOSE); this.setBounds(x, y,w,h); this.setVisible(true); } public FenSimple(String titre, int w, int h){ super(titre); this.setDefaultCloseOperation(EXIT_ON_CLOSE); this.centreEcran(w,h); this.setVisible(true); } public void centreEcran(int w, int h){ Toolkit tk=Toolkit.getDefaultToolkit(); Dimension dim=tk.getScreenSize(); int X=(dim.width-w)/2; int Y=(dim.height-h)/2; this.setBounds(X,Y,300,200); //centre au milieu de la fenêtre } public FenSimple(String titre, int w, int h, Cursor c){ super(titre); this.setDefaultCloseOperation(EXIT_ON_CLOSE); this.setCursor(c); this.centreEcran(w,h); this.setVisible(true); this.setBackground(Color.CYAN); } public static void main (String args[]){ Toolkit atoolkit = Toolkit.getDefaultToolkit(); //new FenSimple("ma première fenêtre ",0,0,atoolkit.getScreenSize().width,atoolkit.getScreenSize().height ); //new FenSimple("deuxième fenêtre ",200,300); //new FenSimple("troisième fenêtre ",200,300,new Cursor(Cursor.HAND_CURSOR)); String titre = "FENETRE"; int hautEcran = atoolkit.getScreenSize().height; for(int i=1; i<=3;i++){ new FenSimple(titre+i, 0,(hautEcran/3)*(i-1),atoolkit.getScreenSize().width, hautEcran/3); } } }