35 lines
1.1 KiB
Java
35 lines
1.1 KiB
Java
import javax.swing.*;
|
|
import java.awt.*;
|
|
|
|
public class Formes extends JComponent{
|
|
|
|
private Image cercle;
|
|
|
|
public Formes(){
|
|
super();
|
|
this.cercle = Toolkit.getDefaultToolkit().getImage("cercles.png");
|
|
}
|
|
|
|
@Override
|
|
protected void paintComponent(Graphics pinceau){
|
|
Graphics secondPinceau = pinceau.create();
|
|
secondPinceau.setColor(Color.GREEN);
|
|
secondPinceau.drawOval(200,200,50,50);
|
|
secondPinceau.setColor(Color.BLUE);
|
|
secondPinceau.drawRect(100,100,50,50);
|
|
secondPinceau.setColor(Color.PINK);
|
|
secondPinceau.setFont(new Font(Font.SERIF,Font.BOLD,24));
|
|
secondPinceau.drawString(">o<",300,300);
|
|
secondPinceau.drawImage(cercle,100,400,this);
|
|
}
|
|
|
|
public static void main(String[] args){
|
|
JFrame fenetre = new JFrame();
|
|
fenetre.setSize(500,500);
|
|
fenetre.setLocation(50,50);
|
|
fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
|
Formes dessin = new Formes();
|
|
fenetre.add(dessin);
|
|
fenetre.setVisible(true);
|
|
}
|
|
} |