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
|
public class TestGraphic extends JFrame implements Runnable
{
static int i;
public JPanel test2;
Graphics lecontexteGr;
public static void main (String[] args)
{
TestGraphic TG;
TG = new TestGraphic();
TG.show();
TG.start();
}
public TestGraphic ()
{
setSize (300,200);
addWindowListener (new WindowAdapter() {
public void windowClosing (WindowEvent événement)
{
System.exit(0);
}
});
test2 = new lePanneau();
getContentPane().add(test2);
}
public void run()
{
i=0;
while (i<100)
{
i++;
update();
}
}
}
class lePanneau extends JPanel {
public void paintComponent (Graphics surface)
{
super.paintComponent(surface);
surface.drawRect(5, 5, 10, 10);
surface.drawArc(20, 20,200, 200, 10, 30);
}
} |
Partager