티스토리 뷰

Computer/Mobile3D

3. Hello MIDlet

DogBull 2007.07.30 17:16
사용자 삽입 이미지

import
javax.microedition.lcdui.*; import javax.microedition.midlet.*; public class Test1 extends MIDlet{ //############################################################################################### //# MIDlet 클래스 추상 메소드 //# [MIDlet 생명주기 1] 응용프로그램이 시작 될 때. //# canvas 클래스의 쓰레드가 live인 동안 응용프로그램은 Activate 상태이다. //############################################################################################### public void startApp(){ Display display= Display.getDisplay(this); //현재 MIDlet에 해당하는 Display 객체를 얻는다. Canvas canvas= new testCanvas(); //Canvas 인스턴스 생성. display.setCurrent(canvas); //파라미터(canvas)를 display한다. } //############################################################################################### //# MIDlet 클래스 추상 메소드 정의 //# [MIDlet 생명주기 2] 전화가 왔을 때와 같은 MIDlet 사용 불가 상태. //############################################################################################### public void pauseApp(){} //############################################################################################### //# MIDlet 클래스 추상 메소드 //# [MIDlet 생명주기 3] 종료될 때. //############################################################################################### public void destroyApp(boolean b){} } class testCanvas extends Canvas{ //############################################################################################### //# Canvas 클래스의 추상 메소드 정의 //############################################################################################### public void paint(Graphics g){ g.setColor(0x000000); g.drawString("Hello MIDlet", this.getWidth()/2, this.getHeight()/2, g.TOP | g.LEFT); } }

Display 객체는 액자,
Canvas 객체는 액자에 넣어질 그림으로 비유될 수 있다.

'Computer > Mobile3D' 카테고리의 다른 글

5. Color Cube  (0) 2007.07.30
5. 3D Draw  (0) 2007.07.30
4. Thread 를 이용한 화면 갱신  (1) 2007.07.30
3. Hello MIDlet  (0) 2007.07.30
2. MIDlet 생명 주기  (0) 2007.07.30
1. Mobile3D  (0) 2007.07.30
댓글
Total
157,718
Today
39
Yesterday
95