[JAVA5] 방향키를 이용해 button 움직이기
Computer/IT/JAVA 2006/09/14 14:37 |파일명 : KeyEvent1.java
- import java.awt.*;
- import java.awt.event.*;
- Button man;
- super(title);
- setLayout(null);
- this.setSize(200, 200);
- man.setBounds(100, 100, 40, 20);
- this.add(man);
- man.addKeyListener(new KeyHandler());
- }
- KeyEvent1 me = new KeyEvent1(" Key 이벤트 활용 ");
- me.setVisible(true);
- }
- int x=man.getX();
- int y=man.getY();
- if(direction.equals("Right")) x+=10;
- else if(direction.equals("Left")) x-=10;
- else if(direction.equals("Down")) y+=10;
- else if(direction.equals("Up")) y-=10;
- man.setLocation(x, y);
- }
- }
- }
'Computer/IT > JAVA' 카테고리의 다른 글
| [JAVA] APPLET - ButtonEvent (0) | 2006/09/18 |
|---|---|
| [JAVA] APPLET - Label 사용예제 (0) | 2006/09/18 |
| [JAVA5] 방향키를 이용해 button 움직이기 (0) | 2006/09/14 |
| [JAVA5] ActionEvent Example (0) | 2006/09/14 |
| [JAVA] InetAddress (0) | 2006/09/14 |
| 콘솔입력받아 배열에 넣기 (0) | 2006/04/16 |
Trackback Address :: http://sarangsai.com/trackback/84
-
Subject: 방향키를 이용해 button 움직이기
Tracked from 광아의 프로그래밍 2006/09/17 13:17 Delete파일명 : KeyEvent1.java import java.awt.*;import java.awt.event.*;public class KeyEvent1 extends Frame { Button man; public KeyEvent1(String title) { super(title); setLayout(null); this.setSize(200, 200); man = new Button("Man"); man.setBounds(100, 100, 40..

댓글을 달아 주세요