28 lines
1.0 KiB
Java
28 lines
1.0 KiB
Java
|
|
import javax.swing.*;
|
||
|
|
import java.awt.*;
|
||
|
|
|
||
|
|
public class formes extends JComponent{
|
||
|
|
protected void paintComponent(Graphics pinceau){
|
||
|
|
Graphics secondPinceau = pinceau.create();
|
||
|
|
secondPinceau.setColor(Color.BLUE);
|
||
|
|
secondPinceau.drawRect(0,0,50,50);
|
||
|
|
secondPinceau.setColor(Color.GREEN);
|
||
|
|
secondPinceau.drawOval(50,60,25,25);
|
||
|
|
secondPinceau.fillOval(50,60,25,25);
|
||
|
|
Color couleur1 = new Color(148,0,211);
|
||
|
|
secondPinceau.setColor(couleur1);
|
||
|
|
secondPinceau.setFont(new Font(Font.SERIF,Font.BOLD,24));
|
||
|
|
secondPinceau.drawString(">o<",100,150);
|
||
|
|
Image image = Toolkit.getDefaultToolkit().getImage("cercles.png");
|
||
|
|
secondPinceau.drawImage(image,10,20,this);
|
||
|
|
}
|
||
|
|
public static void main(String[] args){
|
||
|
|
formes a = new formes();
|
||
|
|
JFrame fenetre = new JFrame();
|
||
|
|
fenetre.setSize(500,500);
|
||
|
|
fenetre.setLocation(100,100);
|
||
|
|
fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||
|
|
fenetre.add(a);
|
||
|
|
fenetre.setVisible(true);
|
||
|
|
}
|
||
|
|
}
|