검색결과 리스트
전체 글에 해당되는 글 238건
- 2009.04.21 JAVA 1
글
JAVA
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;
}
}