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
- OGNL
- 기본
- AWT
- mybatis
- 생성자
- JSP
- Menu
- 전화걸기
- 어노테이션
- 오버로딩
- 국제화
- HTML
- 이클립스
- 클래스
- oracle
- Android
- JavaScript
- 안드로이드
- 메서드
- layout
- 배열
- paint
- 에러페이지
- Java
- Eclips
- Graphic
- Spring
- 예외처리
- struts2
- 메소드
Archives
- Today
- Total
note
Mouse Motion 본문
package com.event; //Mouse Motion
import java.awt.Color;
import java.awt.Frame;
import java.awt.Label;
import java.awt.Button;
import java.awt.Point;
import java.awt.event.ActionEvent;
import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionListener;
import java.awt.event.ActionListener;
public class MouseMotionEx extends Frame implements ActionListener, MouseMotionListener{
Label move = new Label("마우스 따라 다니기", Label.CENTER);
Button exit = new Button("종료");
public MouseMotionEx(){
setTitle("MouseMotion 테스트");
//좌표로 컴포넌트의 위치를 지정할경우 레이아웃을 사용하지 않음
setLayout(null);
move.setBounds(100,50,150,20);//x,y width height
exit.setBounds(250,500,50,30);
move.setForeground(Color.white);
move.setBackground(Color.red);
add(move); //Frame에 Label 등록
add(exit);
//Frame의 x,y width , height
setBounds(300,100,500,600);
setVisible(true);
exit.addActionListener(this);
//Frame 이벤트 소스와 이벤트 리스너가 구현된 객체 연결
addMouseMotionListener(this);
}
public static void main(String[] args) {
new MouseMotionEx();
}
//이벤트 핸들러
public void actionPerformed(ActionEvent e){
System.exit(0);
}
//이벤트 핸들러
public void mouseMoved(MouseEvent e){
Point p = e.getPoint(); //마우스의 포인터의 x,y
move.setLocation(p);
}
//이벤트 핸들러
public void mouseDragged(MouseEvent e){}
}
'자바 > AWT' 카테고리의 다른 글
| Adapter Ex (0) | 2011.12.29 |
|---|---|
| Window Event (0) | 2011.12.29 |
| Key Event (0) | 2011.12.29 |
| Iteam Event (0) | 2011.12.29 |
| 이벤트 처리 (0) | 2011.12.29 |