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 41 42 43 44 45 46 47 48 49 50 51 52
| import java.awt.Color;
import java.awt.Graphics;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Random;
import java.util.Timer;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class Tutorial1 extends JPanel
{
public int radius=25;
public void paintComponent(Graphics g)
{
super.paintComponent(g);
g.setColor(Color.blue);
g.drawOval(250-(radius/2), 250-(radius/2), radius,radius);
radius=radius+10;
// System.out.println(radius);
if(radius<250)
{
paintComponent(g);
}
else
g.fillOval(250, 250, 100,50);
}
public static void main(String[] args)
{
Tutorial1 t =new Tutorial1();
JFrame f=new JFrame();
f.setSize(500,500);
f.setTitle("Test");
f.add(t);
f.setVisible(true);
}
} |
Partager