×

Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    Mar 2004
    Posts
    12

    new screen does not display

    I am trying to display a progress screen when a user attempts to download from the web.


    WaitCanvas creates a progress screen that uses an animation.

    Problem: the waitCanvas object is not displayed, instead the previous screen stays displayed until remoteDetails.run completes it's work and it updates the screeen.

    If I remove the call to run, the animation displays!

    remoteDetails.run does not attempt to update the screen until it has carried out all it's work.


    CODE:

    case EventIds.EVENT_ID_GET_REMOTE_DETAILS: {

    WaitCanvas waitCanvas = new WaitCanvas();
    midlet.display.setCurrent(waitCanvas);
    remoteDetails = new GetRemoteDetails(midlet);
    remoteDetails.run();

    break;
    }


    Anyone offer any suggestions?

  2. #2
    Super Contributor
    Join Date
    Mar 2003
    Location
    Israel
    Posts
    2,280
    If you are performing that code in the MIDlet's main event thread (for instance in commandAction, startApp, keyPressed, etc.) then you are blocking the same thread that is in charge of updating the display. So the thread that updates the screen is only freed after you have performed the long operation.

    You need to perform the long operation in a separate thread.

    By the look of your code, since remoteDetails has a run() method, I'm guessing that it implements the Runnable interface. In that case you have to change the code to:

    Code:
    Thread t = new Thread(remoteDetails);
    t.start();
    shmoove

  3. #3
    Registered User
    Join Date
    Mar 2004
    Posts
    12
    shmoove, thanks for the reply. I am new to java threads and seem to have got the (implement) Runnable interface confused with the (extends) Thread class.

    your code sample cleared this up and I am pleased to report that after a day of tearing out hair it is great to see my app working as it should.

    kevin

Posting Permissions

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