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
| import java.awt.Color;
import java.awt.Graphics;
import java.awt.Image;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import javax.swing.JPanel;
public class Panneau extends JPanel {
public void paintComponent(Graphics g) {
int bande1X[]={1, 1023,1023,1};
int bande1Y[]={1, 1,336, 336};
int bande2X[]={0,1023, 1023,0};
int bande2Y[]={432, 432, 765, 765};
int bande3X[]={0, 1024, 1024, 0};
int bande3Y[]={337, 337, 432, 432};
g.setColor(new Color(0x27233C));
g.drawPolygon(bande1X, bande1Y, 4);
g.drawPolygon(bande2X, bande2Y, 4);
g.setColor(Color.black);
g.fillPolygon(bande3X, bande3Y, 4);
try {
Image img = ImageIO.read(new File("logointro.png"));
g.drawImage(img, 325, 337, this);
//Pour une image de fond
//g.drawImage(img, 0, 0, this.getWidth(), this.getHeight(), this);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
} |
Partager