728x90
728x90
1 import java.applet.Applet;
2 import java.awt.*;
3 import java.awt.Image;
4
5 // 라벨, 색, 그림, 그림불러오기
6
7 /*
8 <applet code="Draw1.class" width=500 height=800>
9 </applet>
10 */
11
12 public class Draw1 extends Applet{
13 Image img;
14 Label lb1, lb2;
15
16 // 실행시에 1회만 호출 되는 부분은 이 부분에 넣는다.
17 // 그림과 라벨의 설정은 프로그램 시작 시에 한번만 하면 되기 때문에 init()메소드 내에 설정
18 public void init(){
19
20 img = getImage(getDocumentBase(), "test.jpg");
21
22 // Label lb1 = new Label("라벨 입니다.");
23 lb1 = new Label("라벨 입니다.");
24 add(lb1);
25 lb2 = new Label("ABCDEFGHI");
26 add(lb2);
27 }
28
29 public void paint (Graphics g){
30
31 int x1 = 40, wd1 = 150, ht1 = 30;
32
33 g.drawLine(x1, 10, x1+wd1, 40); // 선
34
35 g.drawRect(x1, 50, wd1, ht1); // 단형
36 g.fillRect(x1, 90, wd1, ht1); // 단형 채우기
37
38 g.drawOval(x1, 130, wd1, ht1); // 타원
39 g.fillOval(x1, 170, wd1, ht1); // 타원 채우기
40
41 g.drawArc(x1, 210, 50, 50, 0, 270); // 호
42 g.setColor(Color.blue); // 색 넣기
43 g.fillArc(x1 + 100, 210, 50, 50, 0, 270); // 호 채우기
44
45 g.drawArc(x1, 270, 50, 50, 0, 360); // 원
46 g.setColor(new Color(0, 255, 0)); // 색 넣기
47 g.fillArc(x1 + 100, 270, 50, 50, 270, 180); // 원 채우기
48
49 g.drawImage(img, x1, 330, this); // 이미지 파일 불러오기
50 }
51 }
728x90
댓글