tailieunhanh - Lập trình Java cơ bản : Lập trình GUI (Applet) part 4

Lớp Graphics • Vẽ đường thẳng • public void drawLine(int x1, int y1, int x2, int y2); • Vẽ hình chữ nhật • public void drawRect(int x, int y, int width, int height); • Tô một hình chữ nhật • public void fillRect(int x, int y, int width, int height); | Lớp Graphics Vẽ đường thẳng public void drawLine int x1 int y1 int x2 int y2 Vẽ hình chữ nhật public void drawRect int x int y int width int height Tô một hình chữ nhật public void fillRect int x int y int width int height Xoá một vùng chữ nhật public void clearRect int x int y int width int height Vẽ đa giác public void drawPolygon int x int y int numPoint public void drawPolygon Polygon p 16 Lớp Graphics import import public class DemoRect extends Applet public void init Demonstration of some simple figures public void paint Graphics g 70 300 400 250 100 50 130 170 120 70 70 70 int x 280 310 330 430 370 int y 2p0 140 170 70 90 x y Lớp Graphics Applet Viewer Applet Applet started. .