×

Discussion Board

Results 1 to 1 of 1

Hybrid View

  1. #1
    Registered User
    Join Date
    Oct 2012
    Posts
    1

    problem with animation wait screen

    hi all
    I have project to read text file from resource by choosing from list , I want the wait screen is animation by array image in canvas class , but when invoke the canvas class appear one image and didnt appear all image animation
    this code
    import java.io.ByteArrayOutputStream;
    import java.io.IOException;
    import java.io.InputStream;
    import javax.microedition.midlet.MIDlet;
    import javax.microedition.lcdui.*;
    public class KeyPad extends MIDlet implements

    CommandListener,Runnable{

    Display display;

    private Form container,f;

    private Command exit;

    List list;
    StringItem st;

    private TextField field;
    InputStream is;
    CustomGauge wait;
    private Image select;
    Image[] frames;Thread t;
    public KeyPad() {
    display = Display.getDisplay(this);
    st=new StringItem(null,null);
    container = new Form("");
    wait =new CustomGauge();
    f= new Form("");
    t = new Thread(this);
    f.append(st);
    frames = new Image[7];
    String[] options = {"Implicit", "Exclusive", "Multiple"};
    list = new List("List Example", Choice.IMPLICIT, options,
    null);
    list.setCommandListener(this);
    exit = new Command("خروج",Command.EXIT,1);
    container.addCommand(exit);
    for(int i = 0; i < 7; i++)
    {
    try {
    frames[i] = Image.createImage("/frame" + (i+1) +
    ".png");
    select= Image.createImage("/select.png");
    }
    catch (IOException e) {
    e.printStackTrace();
    }
    }
    }

    public void startApp() {
    display.setCurrent(list);
    }
    public void commandAction(Command c, Displayable d) {

    if(c == List.SELECT_COMMAND )
    { st.setText(this.readHelpText(list.getSelectedIndex
    ()));
    System.out.println(list.getSelectedIndex());
    t.start();
    display.setCurrent(wait);
    }
    if(c == exit) {
    notifyDestroyed();
    }
    }public void run() {
    display.setCurrent(f);
    }
    public void pauseApp() {
    }
    public void destroyApp(boolean unconditional) {
    }
    public String readHelpText(int mm)
    {
    {
    is= getClass().getResourceAsStream(Integer.toString(mm
    +1)+".txt");
    }
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    try {
    byte[] bufferByte = new byte[1];
    while (is.read(bufferByte) != -1) {
    baos.write(bufferByte);
    }
    return new String(baos.toByteArray(),"UTF-8");
    } catch (Exception e) {
    System.out.println("Unable to create stream");
    }
    return null;
    }
    public class CustomGauge extends Canvas implements Runnable
    {
    Thread thread;
    int nextFrame;
    public CustomGauge()
    {
    nextFrame = 0;
    thread = new Thread(this);
    thread.start();
    }
    protected void paint(Graphics g)
    {
    g.drawImage(frames[nextFrame], (getWidth() / 2) - 40, getHeight

    ()/2 - 40, Graphics.TOP|Graphics.LEFT);
    }
    public void run()
    {
    while (true) {
    try {
    if(nextFrame == 6) {
    nextFrame = 0;
    }
    else {
    nextFrame++;
    }
    repaint();
    Thread.sleep(200);
    }
    catch (InterruptedException ee)
    {
    break;
    }
    }
    }
    }
    }
    but when I display the canvas class in methode startup
    public void startApp() {

    display.setCurrent(wait);

    }
    it work correctly

    please any one Edit on my code
    thanks for all
    Last edited by iraqyiraqy; 2012-10-25 at 14:31.

Similar Threads

  1. How to make animation for waiting (not using wait dialog)
    By Kaz32 in forum Symbian User Interface
    Replies: 1
    Last Post: 2012-06-01, 06:27
  2. I want to make wait Screen
    By buffon2009 in forum Mobile Java General
    Replies: 4
    Last Post: 2011-01-13, 07:04
  3. Hide the animation in a wait note
    By ahlmans in forum Symbian User Interface
    Replies: 2
    Last Post: 2008-02-28, 08:27
  4. Please wait screen
    By diplm in forum Mobile Java General
    Replies: 2
    Last Post: 2004-06-11, 15:27
  5. screen flicker during animation
    By nkn_motoko in forum Mobile Java General
    Replies: 1
    Last Post: 2001-11-06, 21:45

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×