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
|
import java.awt.event.*;
import java.awt.*;
import javax.swing.*;
public class TestGraphic extends JFrame
{
public static void main (String[] args)
{
new TestGraphic().show();
}
public TestGraphic ()
{
setSize (300,200);
addWindowListener (new WindowAdapter() {
public void windowClosing (WindowEvent événement)
{
System.exit(0);
}
});
JPanel test2;
Graphics lecontexteGr;
test2 = new lePanneau();
getContentPane().add(test2);
lecontexteGr = test2.getGraphics();
lecontexteGr.drawRect(5, 5, 10, 10);
}
}
class lePanneau extends JPanel {
public void paintComponent (Graphics surface)
{
super.paintComponent(surface);
}
} |
Partager