j'ai trouvé ,un peu mieux compris grace a un autre site:
http://www.self-access.com/java/jvBonjour.htm
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
public class Composant extends Applet implements ActionListener {
String commande = "cercle1";
Button bn, bg ;
Font fgras, fnormal, fitalic, fdef;
int i,x,y;
int rayon=200;
public void init() {
add(bn = new Button ("cercle n1" ));
add(bg = new Button("cercle n2" ));
bn.addActionListener(this);
bg.addActionListener(this);
fgras = new Font("Helvetica",Font.BOLD,40);
fnormal = new Font("Helvetica",Font.PLAIN,40);
fitalic = new Font("Helvetica",Font.ITALIC,40);
fdef = new Font("Helvetica",Font.PLAIN,12);
}
public void actionPerformed(ActionEvent e) {
commande = e.getActionCommand();
repaint();
}
public void paint(Graphics g) {
g.drawString("Exemple", 20, 180);
if (commande.equals("cercle n1" )) cercle1(g,0);
if (commande.equals("cercle n2" )) cercle1(g,10);
}
void cercle1(Graphics gege,int delta)
{
rayon=200;
for(i=0;i<100;i++)
{
x=400+delta+(int)(Math.sin(3.14159/50*i)*rayon);
y=300+(int)(Math.cos(3.14159/50*i)*rayon);
gege.drawLine(400,300,x,y);
}
}
}