1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
|
Image imgStade, imgJoueurs;
JLayeredPane jlpEnsemble;
JPanel jpStade, jpJoueurs;
jpStade = new JPanel();
jpStade.setBounds(0, 0, 800, 400);
jpJoueurs = new JPanel();
jpJoueurs.setBounds(0, 0, 800, 400);
jlpEnsemble = new JLayeredPane();
jlpEnsemble.setPreferredSize(new Dimension(800, 400));
jlpEnsemble.add(jpJoueurs, new Integer(1));
jlpEnsemble.add(jpStade, new Integer(2));
this.getContentPane().add(jlpEnsemble);
pack();
this.setVisible(true);
Dimension dim = jpStade.getSize();
imgStade = jpStade.createImage(dim.width, dim.height);
Graphics g = imgStade.getGraphics();
g.setColor(Color.green);
g.fillRect(0, 0, dim.width, dim.height); // Dessin du stade
Dimension dim2 = jpJoueurs.getSize();
imgJoueurs = jpJoueurs.createImage(dim2.width, dim2.height); // Image qui servira à dessiner les joueurs par la suite |
Partager