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 36 37 38 39 40
|
class Toto extends JFrame implements ActionListener
{
Timer t;
static int i;
Toto()
{
setTitle("Ma fenetre");
Container c=(Container) getContentPane();
setBound(10,10,900,900);
JPane panel= new JPanel;
c.add(panel);
setVisible(true);
}
public void init()
{
i=0;
}
public void start()
{
t=new Timer(500,this);
t.start();
}
public void actionPerformed(ActionEvent e)
{
repaint();
}
public void paint(Graphics g)
{
g.setColor(Color.blue);
g.fillRect(10,250,10+i,80);
i=i+10;
requestFocus();
}
} |