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
- 기본
- 어노테이션
- 이클립스
- mybatis
- AWT
- 배열
- 메소드
- 에러페이지
- Android
- 생성자
- paint
- struts2
- 메서드
- Eclips
- oracle
- HTML
- OGNL
- Java
- Spring
- Graphic
- 오버로딩
- Menu
- layout
- 클래스
- JavaScript
- 국제화
- 예외처리
- 전화걸기
- JSP
- 안드로이드
Archives
- Today
- Total
note
Graphic paint 사용법 본문
package com.graphic3;//Graphic paint 사용법
import java.awt.*;
import java.awt.event.*;
import java.awt.event.MouseMotionListener;
public class GraphicsEx2 extends Frame implements MouseMotionListener{
int x= 0;
int y= 0;
public static void main(String[] args) {
new GraphicsEx2("GraphicsEx2");
}
public GraphicsEx2(String title){
super(title);
addMouseMotionListener(this);
//익명내부 클래스 형태의 이벤트 처리
addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent we){
System.exit(0);
}
});
//Frame
setBounds(100,100,500,500);
setVisible(true);
}
public void paint(Graphics g){
g.drawString("마우스를 움직여보세요.",10,50);
g.drawString("*",x,y);
}
public void mouseMoved(MouseEvent me){
x =me.getX();
y =me.getY();
repaint();//paint (graphic g)를 호출
//paint를 직접 호출할 수 없기때문에 repaint로 호출
}
public void mouseDragged(MouseEvent me){}
}//class
'자바 > AWT' 카테고리의 다른 글
| Graphic paint (0) | 2011.12.30 |
|---|---|
| Graphic 이미지 넣기 (0) | 2011.12.29 |
| Graphic 도형 그리기 (0) | 2011.12.29 |
| Graphic Color (0) | 2011.12.29 |
| Graphic Font (0) | 2011.12.29 |