Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- Java
- 에러페이지
- Menu
- HTML
- 메서드
- paint
- oracle
- JavaScript
- 전화걸기
- 오버로딩
- Android
- 이클립스
- 어노테이션
- 예외처리
- Graphic
- struts2
- JSP
- 배열
- 기본
- layout
- AWT
- Spring
- 국제화
- OGNL
- 안드로이드
- mybatis
- 메소드
- 생성자
- Eclips
- 클래스
Archives
- Today
- Total
note
Graphic 도형 그리기 본문
package com.graphic3;//Graphics 도형 그리기
import java.awt.*;
import java.awt.event.*;
import java.awt.Frame;
import java.awt.Color;
class GraphicFrame extends Frame{
Color redColor;
//Paint 메서드 오버라이딩
//paint 메소드를 재정의하면 프로그램 구동시 자동으로 호출됨
public void paint(Graphics g){
redColor = new Color(255,0,0);
g.setColor(redColor);
//사각형 x y width height
g.drawRect(10,30,40,40);
//원(타원)
g.fillOval(70,30,40,40);
//꼭지점 좌표
int x[] = new int[]{10,30,50,40,20};
int y[] = new int[]{107,90,107,130,130};
//다각형
g.drawPolygon(x,y,x.length);
//모서리가 둥근 사각형
// x y width height arWidth arcHeight(마지막 2개는 모깍기 정도)
g.drawRoundRect(70,90,40,40,10,10);
//선 시작x 시작y 끝x 끝 y
g.drawLine(150,50,200,100);
g.drawLine(200, 50, 150, 100);
} //문자열 x,y
public GraphicFrame(){
addWindowListener (new WindowAdapter(){
public void windowClosing(WindowEvent e){
dispose();
System.exit(0);
}});
}
}
public class GraphicTest01 {
public static void main(String[] args) {
GraphicFrame f = new GraphicFrame();
f.setSize(270,150);
f.setVisible(true);
}
}
'자바 > AWT' 카테고리의 다른 글
Graphic paint 사용법 (0) | 2011.12.30 |
---|---|
Graphic 이미지 넣기 (0) | 2011.12.29 |
Graphic Color (0) | 2011.12.29 |
Graphic Font (0) | 2011.12.29 |
Adapter Ex (0) | 2011.12.29 |