JAVA

프로그래밍 2009. 4. 21. 15:00

import org.kwis.msp.lcdui.*;
import java.io.IOException;

public class AnchorEx extends Jlet
{
 protected void startApp(String args[])
 {
  Display dp = Display.getDefaultDisplay();
  MoveCard card = new MoveCard();
  dp.pushCard(card);
 }

 protected void destroyApp(boolean b){}

}
class MoveCard extends Card {
 int anchor = Graphics.VCENTER | Graphics.HCENTER;
 int x = 0, y = 0;
 int count = 0;

 protected void paint(Graphics g) {
  Image img = null;
  try {
   img = Image.createImage("folder.gif");
  }catch(IOException e){}

  g.translate(x, y);
  g.setColor(0xffffff);
  g.fillRect(0, 0, getWidth(), getHeight());

  //이미지를 화면에 출력함
  g.drawImage(img, getWidth()/2, getHeight()/2, anchor);
 }
 public boolean keyNotify(int type, int keyCode) {
  if(type == EventQueue.KEY_PRESSED) {
   switch(count % 3) {
      case 0:
         x = 20;  y = 20;
         anchor = Graphics.BOTTOM | Graphics.RIGHT;  break;
      case 1:
         x = 0;  y = 0;
         anchor = Graphics.TOP | Graphics.LEFT;  break;
      case 2:
         x = 10;  y = 10;
         anchor = Graphics.VCENTER | Graphics.HCENTER;
         break;
   }
   repaint(); count++;
  }
  return true;
 }
}

'프로그래밍' 카테고리의 다른 글

JAVA  (0) 2009.04.30
JAVA  (1) 2009.04.28
JAVA  (1) 2009.04.28
JAVA  (0) 2009.04.26
JAVA  (0) 2009.04.23
JAVA  (1) 2009.04.20
JAVA  (0) 2009.04.19
JAVA  (0) 2009.04.16
JAVA  (1) 2009.04.15
JAVA  (0) 2009.04.12

설정

트랙백

댓글