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
| package applet;
import java.awt.*;
import java.applet.*;
public class DrawExample extends Applet {
Font bigFont;
Color redColor;
Color weirdColor;
Color bgColor;
public void init() {
bigFont = new Font("Arial", Font.BOLD, 16);
redColor = Color.red;
weirdColor = new Color(60, 60, 122);
bgColor = Color.pink;
setBackground(bgColor);
}
public void stop() {
}
public void paint(Graphics g) {
g.setFont(bigFont);
g.drawString("Shapes and Colors", 80, 20);
g.setColor(redColor);
g.drawRect(100, 100, 100, 100);
g.fillRect(110, 110, 80, 80);
g.setColor(weirdColor);
g.fillArc(120, 120, 60, 60, 0, 360);
g.setColor(Color.yellow);
g.drawLine(140, 140, 160, 160);
g.setColor(Color.black);
}
} |
Partager