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 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
|
public class MaFenetre extends JFrame{
public static String title="mon titre";
public int fenetreWidth = 700;
public int fenetreHeight = 550;
public static Dimension size = new Dimension (700,550);
public PanneauBuild panneauBuild = new PanneauBuild();
public PanneauJeu panneauJeu = new PanneauJeu();
public PanneauScore panneauScore = new PanneauScore();
public MaFenetre() {
this.setTitle(title);
this.setSize(size);
this.setBackground(Color.white);
this.setResizable(true);
this.setLocationRelativeTo(null);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//panneauBuild.setBounds(0, 0, (this.getWidth()/8), this.getHeight());
//panneauScore.setBounds(this.getWidth()/8,0,(this.getWidth()-this.getWidth()/8),this.getHeight()/8);
//panneauJeu.setBounds(this.getWidth()/8, this.getHeight()/8, (this.getWidth()-this.getWidth()/8), (this.getHeight()-this.getHeight()/8));
init();
}
public void init() {
while(true) {
//placement des différents panneau + rafraichissement
if ((this.getWidth() != fenetreWidth) || (this.getHeight() != fenetreHeight)) { //pour changement grandeur fenetre
fenetreWidth = this.getWidth();
fenetreHeight = this.getHeight();
panneauBuild.setBounds(0, 0, (this.getWidth()/8), this.getHeight());
panneauScore.setBounds(this.getWidth()/8,0,(this.getWidth()-this.getWidth()/8),this.getHeight()/8);
panneauJeu.setBounds(this.getWidth()/8, this.getHeight()/8, (this.getWidth()-this.getWidth()/8), (this.getHeight()-this.getHeight()/8));
System.out.println("fenetre " + this.getWidth());
this.getContentPane().add(panneauBuild);
this.getContentPane().add(panneauScore);
this.getContentPane().add(panneauJeu);}
//panneauJeu.repaint();
this.setVisible(true);
panneauJeu.repaint();
try {
Thread.sleep(10);
} catch (InterruptedException e) {
e.printStackTrace();
}
//screen.setBackground(Color.blue);
//this.add(screen);
}
}
public static void main(String args[]) {
MaFenetre frame = new MaFenetre();
}
} |
Partager