title: J2me+images in form
body: <p>I want to make the clock application where user enters the number in the textbox and click ok then user get the number at every 1 sec.
  Example if user enter 5 then the timer start the display screen shows the number 1,2,3,4,5,0,1,2,3,4,5,0,1,2,3,...so on.</p>
  
  <p>Now i had taken form and text field for user to enter the number,then a timer which will change the number at every second.and 10 images of number (0-9).As i want to dispaly the number in very large size.Now i had implement this logic in below way:-</p>
  
  <blockquote>
    <p>public class Clock extends MIDlet implements CommandListener {</p>
  
  <pre><code>public Command GO, Exit;
  TextField TxtData;
  protected Display display;
  int number, counter;
  Form form;
  private Timer timer;
  private TestTimerTask task;
  boolean increment, time;
  private StringItem s1 = new StringItem("", "");
  Image image0;
  Image image1;
  Image image2;
  Image image3;
  Image image4;
  Image image5;
  Image image6;
  Image image7;
  Image image8;
  Image image9;
  Image[] secondAnimation;
  protected void startApp() {
      display = Display.getDisplay(this);
      increment = true;
      time = false;
      form = new Form("Clock");
      TxtData = new TextField("Number:-", "", 5, TextField.NUMERIC);
      try {
          image0 = Image.createImage("/images/0.png");
          image1 = Image.createImage("/images/1.png");
          image2 = Image.createImage("/images/2.png");
          image3 = Image.createImage("/images/3.png");
          image4 = Image.createImage("/images/4.png");
          image5 = Image.createImage("/images/5.png");
          image6 = Image.createImage("/images/6.png");
          image7 = Image.createImage("/images/7.png");
          image8 = Image.createImage("/images/8.png");
          image9 = Image.createImage("/images/9.png");
             secondAnimation = new Image[]{image0,image1,image2, image3, image4, image5, image6, image7, image8, image9};
  
      } catch (IOException ex) {
        System.out.println("exception");
      }
      GO = new Command("Go", Command.OK, 1);
      Exit = new Command("Exit", Command.EXIT, 2);
      form.append(TxtData);
      form.append(s1);
  
      form.addCommand(GO);
      form.addCommand(Exit);
      form.setCommandListener(this);
      display.setCurrent(form);
  }
  
  protected void pauseApp() {
  }
  
  protected void destroyApp(boolean unconditional) {
      timer.cancel();
      notifyDestroyed();
  }
  
  public void commandAction(Command cmnd, Displayable dsplbl) {
      String label = cmnd.getLabel();
      if (label.equals("Go")) {
          try {
              System.out.println("txt==" + (TxtData.getString()));
              if (!TxtData.getString().equalsIgnoreCase("")) {
                  counter = Integer.parseInt(TxtData.getString());
                  if (time) {
                      timer.cancel();
                      task.cancel();
                  }
                  number = 1;
                  timer = new Timer();
                  task = new TestTimerTask();
                  timer.schedule(task, 1000, 1000);
  
              }
          } catch (NumberFormatException ex) {
              System.out.println("exception");
          }
  
      } else if (label.equals("Exit")) {
          destroyApp(true);
      }
  
  }
  
  private class TestTimerTask extends TimerTask {
  
      public final void run() {
          time = true;
  
          s1.setText(""+ number);
           if (counter &lt; 10) {
              form.append(secondAnimation[0]);
              form.append(secondAnimation[0]);
              form.append(secondAnimation[number]);
          } else if (counter &lt; 100) {
               form.append(secondAnimation[0]);
              form.append(secondAnimation[(number % 100) / 10]);
              form.append(secondAnimation[(number % 10)]);
          } else if (counter &lt; 1000) {
              form.append(secondAnimation[(number % 10)]);
              form.append(secondAnimation[(number % 100) / 10]);
              form.append(secondAnimation[(number / 100)]);
          }
          number++;
          if (number == counter + 1) {
              number = 0;
          }
      }
  } }
  </code></pre>
  </blockquote>
  
  <p>But as the form goes on appending the image as timer moves it is not showing the desired output!</p>
  
  <p>I had tried to do it through LWUIT but as i had user 10 .png files and adding LWUIT.jar file make the size of .jar file 557kb which is very heavy.</p>
  
  <p>So i want to do it through normal forms only.</p>
  
  <p>I cant use canvas as the keypad can vary like (touch,qwerty etc).So i need to do normal form or LWUIT only.Can anyone please help me for this.</p>