WIPI 프로그래밍 수업~~!!

아래 KISS 버튼을 누르면 LOVE그림이 뜨는 아주 간단한 실습^^


사용자 삽입 이미지


주 코드는 다음과 같다.

 protected void startApp(String[] arg0) {
      displayLCD = Display.getDefaultDisplay();
      ShellComponent shell = new ShellComponent();
      Image imgButton = null;
 
  try
 {
      imgButton = Image.createImage("kiss.gif");
  }
  catch (IOException e) {
       System.out.println("Error BABO");
       System.out.println(e);
  }
 
  ButtonComponent button = new ButtonComponent(" KISS",imgButton);
  button.setActionListener(new ActionListenerHandler(), shell);
 
  shell.setCommand(button, true);
 
  displayLCD.pushCard(shell.getCard());
  }


 

class ActionListenerHandler implements ActionListener {
 
  public void action(Component cmp,Object obj)
  {
   Image imgButton2 = null;
   
   try
   {
    imgButton2 = Image.createImage("/heart.gif");
   }catch(IOException e)
   {
    System.out.println(e);
   }
   ShellComponent shell  = (ShellComponent)obj;
   LabelComponent lb1 = new LabelComponent(" I Love You");
   
   LabelComponent lb2 = new LabelComponent(" LOVE",imgButton2);
   
   shell.setTitle(lb1);
   shell.setWorkComponent(lb2);
  }
 
 
 
 }
http://serapian.pe.kr/trackback/38 관련글 쓰기