J2ME update gui while running MIDlet

Hello all,
I've got a method in my MIDlet which is to show a new form for about 2 seconds and then revert back to the application. It already does all of it's calculations right but it simply does not update the GUI until after the 'return' statement.
Does anybody know why it does not update the GUI before waiting those two seconds and how could I make it do that? Below is my (greatly oversimplified) code.
     public int Throwing(int diceResult)
               Form fi = new Form( "Dice" );
               fi.append("lalala");
               getDisplay().setCurrent( fi );
          Thread currentThread = Thread.currentThread();
          try {
               synchronized(this)
               System.out.println("waiting");
                 wait( 2000 );
               catch ( InterruptedException ie )
                    System.out.println("Exception caught");
               System.out.println("Returning");
             return diceResult;
     }

What do you mean "the main 'UI' thread continues'. Of course it does. Otherwise your MIDlet becomes unresponsive, as you have seen.
I imagine what you want is something to be done when Throwing() finishes (like setting a new displayable with the results). In that case you have to make that part of the thread that calls Throwing(). Something like this, maybe:
public void run() {
  int result = Throwing(5);
  Form f = new Form("Results");
  f.append("The result is " + result);
  getDisplay().setCurrent(f);
}shmoove

Similar Messages

  • Updating HRP1001 while running actions

    Hi Experts,
    While running actions the om infotypes like IT1001 is updated. Could You please tell me as where this configurations are made?
    Like while running a hire action there is a P-A008-S relation created in HRP1001, where is it configured that with Action 'HIRE'  infotype 1001 needs to be updated?
    Please suggest.....
    Thanks
    Akash
    Edited by: Akashdeep Basu on Aug 21, 2009 6:13 PM
    Edited by: Akashdeep Basu on Aug 21, 2009 6:14 PM

    Its configured at table T77S0
    PLOGI ORA X

  • Field not getting updated in BDC while running in background

    Hi Friends,
    I'm executing a BDC transaction to update the Alternate Tax Classification (VBAK_TAXK1) field in Sales Order. I'm passing value 1 to the field and then saving it directly. While running the BDC in background, the field is not getting updated. On the other hand i checked it running in foreground, the field got updated without any error message.
    Can anybody help me advicing why the field is not getting updated in background?
    Thanks,
    Bestin

    Hi ,
    Check the the log if you are using a session method and if call transaction then capture the messages for the same,
    Because in the foreground the BDC will update the records even if there is a warning message nut in background it will not update. So check the data which you are inserting and try avoid the warning messages also so that it can run smoothly in backfround.
    Thanks & Regards
    Jyo

  • Error while running J2ME  program in KtoolKit

    hi,
    i am doing my project in j2me as i m developing a Jabber client .where my Client application has to connect jabber server through GPRS...
    so while running the project in KToolKt it ask that client application wants to send the information this requires airtime which may cost you money.is this ok?(TCP)
    after clicking on yes option program goes in deadlock...thorws following error message
    Error
    =====
    Warning: To avoid potential deadlock, operations that may block, such as
    networking, should be performed in a different thread than the
    commandAction() handler.
    ===================
    plz send me solution if you know....
    regards...

    jhd
    hi.
    this is a common error whenever we are accesing some other basedir other than current base we have to access that via new thread
    i.e suppose i have written the code to make HttpConnection in command Action we can not access it via same thread so we ahave to create another thread and from that thread we have to call our function in which we are making HttpConnection or any RMS operation......
    if(c == connectionCommand)
    new Thread(new Runnable() {
              public void run() {
                makeConnection();               
    }).start();          
    }in this code when you are pessing connectionCommand it will create new thread and from that thread it will call makeConnaction in which we have to write code to establish connection.
    i hope this will solve your problem.
    Regards,
    Jasmit vala.
    rajputjasmit@ yahoo.co.in

  • Error while running batch update statement

    Hi
    We are experiencing the below error while running the batch update statement where in the IN clause have more than 80,000 entries. The IN clause is already handled for max 1000 values so it has multiple or clause
    like update...where id in (1,2...999) OR id in (1000,1001........) OR Id in ()...
    Error at Command Line:1 Column:0
    Error report:
    SQL Error: ORA-00603: ORACLE server session terminated by fatal error
    ORA-00600: internal error code, arguments: [kghfrh:ds], [0x2A9C5ABF50], [], [], [], [], [], []
    ORA-00600: internal error code, arguments: [kkoitbp-corruption], [], [], [], [], [], [], []
    00603. 00000 - "ORACLE server session terminated by fatal error"
    *Cause: An ORACLE server session is in an unrecoverable state.
    *Action: Login to ORACLE again so a new server session will be created
    Is there a limitation of oracle or some bug?
    Thanks

    http://download.oracle.com/docs/cd/B19306_01/server.102/b14237/limits003.htm
    The limit on how long a SQL statement can be depends on many factors, including database configuration, disk space, and memoryI think you're over this limit.
    The only way is creating a temporary table with all the values and using
    IN (select ...)Max
    http://oracleitalia.wordpress.com

  • Error while running base line update

    I am getting below error while running baseline update in endeca environment. please help me out to resolve this issue.
    ./baseline_update.sh
    WARNING: /opt/endeca/PlatformServices/6.1.0/j2sdk/bin/java does not exist
    WARNING: Using java in /usr/java/jdk1.6.0_25/bin/java
    [11.29.12 13:15:00] INFO: Checking definition from AppConfig.xml against existing EAC provisioning.
    [11.29.12 13:15:02] INFO: Definition has not changed.
    [11.29.12 13:15:02] INFO: Starting baseline update script.
    [11.29.12 13:15:02] INFO: Acquired lock 'update_lock'.
    [11.29.12 13:15:02] INFO: Downloading config files from Web Studio.
    [11.29.12 13:15:02] INFO: [ITLHost] Starting shell utility 'emgr_update_get_ws_settings'.
    [11.29.12 13:15:03] SEVERE: Utility 'emgr_update_get_ws_settings' failed. Refer to utility logs in [ENDECA_CONF]/logs/shell on host ITLHost.
    Occurred while executing line 13 of valid BeanShell script:
    10| if (Forge.isDataReady()) {
    11| if (ConfigManager.isWebStudioEnabled()) {
    12| // get Web Studio config, merge with Dev Studio config
    13| ConfigManager.downloadWsConfig();
    14| ConfigManager.fetchMergedConfig();
    15| } else {
    16| ConfigManager.fetchDsConfig();
    [11.29.12 13:15:03] SEVERE: Caught an exception while invoking method 'run' on object 'BaselineUpdate'. Releasing locks.
    Caused by java.lang.reflect.InvocationTargetException
    sun.reflect.NativeMethodAccessorImpl invoke0 - null
    Caused by com.endeca.soleng.eac.toolkit.exception.AppControlException
    com.endeca.soleng.eac.toolkit.script.Script runBeanShellScript - Error executing valid BeanShell script.
    Caused by com.endeca.soleng.eac.toolkit.exception.EacComponentControlException
    com.endeca.soleng.eac.toolkit.utility.Utility run - Utility 'emgr_update_get_ws_settings' failed. Refer to utility logs in [ENDECA_CONF]/logs/shell on host ITLHost.

    Welcome to forum, Please raise only one thread for same problem..
    error while running base line update
    -RMishra

  • Itunes says I must update to 11.1, but everytime I try to run it I get an error message saying:  "an error occured while running installation"  Help?

    Itunes says I must update to 11.1, but everytime I try to run it I get an error message saying:  "an error occured while running installation"  Help?

    The full message reads:  "Errors occurred during installation before iTunes could be configured.  Your system has not been modified.  To complete the installation, run the installer again.  Click finish to exit the installer."
    I have run it again and get the same message.  Have rebooted and tried again.  Same results.

  • While running an update in Itunes i received an error message - Unable to locate component because AVFoundationCF.dll was not found. Then Itunes was not installed correctly. Error 7 (windows error 126) Do I have to reinstall and will I loose all my music?

    While running an update in itunes (not installing), it stopped in the middle of the update and i receceived the following messages:
    Application failed to start because AVFoundationCF.dll was not found. Reinstalling itunes may fix the problem. Then "itunes was installed incorrectly. Please reinstall itunes Error 7 (Windows error 126)".  If i uninstall and reinstall itunes will I lose all of my music, etc.?

    Go to Control Panel > Add or Remove Programs (Win XP) or Programs and Features (later)
    Remove all of these items in the following order:
    iTunes
    Apple Software Update
    Apple Mobile Device Support (if this won't uninstall press on)
    Bonjour
    Apple Application Support
    Reboot, download iTunes, then reinstall, either using an account with administrative rights, or right-clicking the downloaded installer and selecting Run as Administrator.
    The uninstall and reinstall process will preserve your iTunes library and settings, but ideally you would back up the library and your other important personal documents and data on a regular basis. See this user tip for a suggested technique.
    Please note:
    Some users may need to follow all the steps in whichever of the following support documents applies to their system. These include some additional manual file and folder deletions not mentioned above.
    HT1925: Removing and Reinstalling iTunes for Windows XP
    HT1923: Removing and reinstalling iTunes for Windows Vista, Windows 7, or Windows 8
    tt2

  • HT1222 I get "An error has occurred" followed by "The operation was cancelled.(3072)" when I try to update to iTunes 11.0.3 while running OS 10.8.3. Whats up?

    I get "An error has occurred" followed by "The operation was cancelled.(3072)" when I try to update to iTunes 11.0.3 while running OS 10.8.3. Whats up?

    See if this is any help:
    https://discussions.apple.com/thread/4150266?start=0&tstart=0

  • While Running baseLine update with Endeca getting Error with ATG11

    HI All,
    While running the baseline update for endeca getting below error,Please help me to resolve this issue
    [11.26.14 18:26:36] INFO: Checking definition from AppConfig.xml against existing EAC provisioning.
    [11.26.14 18:26:39] INFO: Definition has not changed.
    [11.26.14 18:26:39] INFO: Starting baseline update script.
    [11.26.14 18:26:39] INFO: Acquired lock 'update_lock'.
    [11.26.14 18:26:40] INFO: [ITLHost] Starting shell utility 'cleanDir_cas-output'.
    [11.26.14 18:26:40] SEVERE: Error communicating with EAC agent while starting utility 'cleanDir_cas-output'.
    Occurred while executing line 8 of valid BeanShell script:
    5|    if (LockManager.acquireLock("update_lock")) {
    6|      // clean directories
    7| CAS.cleanCumulativePartials();
    8|      Dgidx.cleanDirs();
    9|
    10|      // run crawl and archive any changes in dvalId mappings
    11| CAS.runBaselineCasCrawl("CRS-last-mile-crawl");
    [11.26.14 18:26:40] SEVERE: Caught an exception while invoking method 'run' on object 'BaselineUpdate'. Releasing locks.
    Caused by java.lang.reflect.InvocationTargetException
    sun.reflect.NativeMethodAccessorImpl invoke0 - null
    Caused by com.endeca.soleng.eac.toolkit.exception.AppControlException
    com.endeca.soleng.eac.toolkit.script.Script runBeanShellScript - Error executing valid BeanShell script.
    Caused by com.endeca.soleng.eac.toolkit.exception.EacCommunicationException
    com.endeca.soleng.eac.toolkit.utility.Utility start - Error communicating with EAC agent while starting utility 'cleanDir_cas-output'.
    Caused by com.endeca.eac.client.EACFault
    sun.reflect.NativeConstructorAccessorImpl newInstance0 – null
    Thanks,
    Mahesh Chinchure

    It sounds like you might be working with Endeca Commerce products - this forum is for Endeca Information Discovery.
    You might try posting your questions on one of these forums:
    Oracle Commerce
    Technical Questions

  • Is it safe to use SwingUtilities.invokeLater(), while updating GUI?

    Hi,
    I am updating GUI components in synchronized block which is runinng on main() thread my application hangs, but if I use SwingUtilities.invokeLater(...) then it runs fine.
    My question is:
    Is it safe to use SwingUtilities.invokeLater(...) in synchronized block.
    Edited by: Amol_Parekh on Nov 1, 2007 1:28 AM

    Paul Hyde in his "Java Thread Programming" (great book!!!) says it is.
    With invokeLater() you say to the Thread Scheduler you want that code to run on the Swing thread. In fact, if that is the only thing you do in the synchronized block I think it is unnecessary.
    Greetings,
    astrognom

  • Error While Updating Driver... {-5011 : 0x80040707} While Running Se

    When I attempt to install the latest patch, the process begins and almost instantly I get the following error message, and I've included the information from the "details" log as welll... An error {-50 : 0x80040707} has occurred while running the setup?Error Information:>SetupDLL\SetupDLL.cpp (548)
    pAPP:Creative Sound Blaster Audigy, Audigy 2 series and Audigy 4 series Driver
    PVENDOR:Creative Technology Ltd.
    PGUID:AAF283AE-985D-4B8A-AFEC-A742D5A797E9
    $9..0.429ice Pack 2 (2600) IE 7.0.6000.644?Any assistance would be greatly appreciated. Thanks.

    A bump for this, still looking for help. By the way, card works fine, I just can't get the latest drivers. Any assistance would be appreciated.

  • Best way to update GUI

    Hi, I have a 'business model' class which holds all my variables that are displayed on my GUI which is a seperate class. As these variables change quite frequently while running the program I need some advise on the best way to update my GUI as need be. I'm using a controller with actionListeners to deal with changes going in the opposite direction. So can I manipulate this approach to suit my needs or should I implement Observable which I've read somewhere else?

    user8844058 wrote:
    Yea that sounds viable to me too DrClap I just can't seem to find any examples of it in action! Would you use events in a non GUI class to achieve this?A bit late - NY time here.
    Example:
    1. User enters data on a GUI;
    2. A button is hit on the GUI and some data is taken as user entries and sent to the contoller;
    3. The controller uses that data and acts as a dispatcher to act on what is requested by calling whatever business logic is required, and the model gets populated appropriately;
    4. Once the model is populated the relevant results are returned to the GUI;
    5. The GUI now represents the results of that population.
    I realize you marked your question as answered, but was, or is your question: "how does (or what is the best or most oftenly used way that) the GUI (view) gets, or knows to get the results of the request?"
    Edited by: abillconsl on Apr 13, 2011 12:42 PM

  • Refreshing GUI while MultiThreading

    I am trying to refresh a GUI while calling a class that extends the Thread class.My code looks similiar to this:
    myThreadingClass mtc=new myThreadingClass();
    mtc.start();
    while(mtc.isAlive()){
    repaint();
    invalidate():
    The isAlive() is never returning false! ? ! I somehow need to do the repaint while waiting for the thread to finish. I had a mtc.join() before that worked and went on in the program, but I did not have any way to refresh the GUI with the mtc.join().
    Any one have any good ideas?

    If mtc.isAlive() is always returning true then obviously it hasn't exitted myThreadingClass.run() yet.
    So you need to look at what causes run() to exit there.
    Also you needto make thread safe calls to Swing by using the SwingUtilities class. Trying to update a Swing component from another thread is inherently unsafe because Swing is non-reentrant.
    - Also : You can repaint then invalidate().... should swap that around.
    - Also : You're refreshing the screen in a while loop without any delays.
    Try putting in a sleep() for a little bit.
    regards,
    Owen
    while ( mtc.isAlive() )
         // IMPORTANT : You can't update a Swing component in another
         // Thread.  You must update it in a "Swing friendly" manner.
         // Hence this helper function.
         try
              Thread.sleep ( 1000 );     // refresh screen once a second... can be changed
         catch (InterruptedException ignore )
         final Runnable runnable = new Runnable()
             public void run()
                  invalidate();
                  repaint();
             } // run
         };    // runnable
         SwingUtilities.invokeLater(runnable);
    }

  • Error while running a job in background

    Hi,
      I got the following error message while running the job in background.
    "Step 001 started .
    Control Framework: Fatal error - GUI cannot be reached.
    ABAP/4 processor: RAISE_EXCEPTION
    Job cancelled"
    What is the reason for this error and how to correct it?

    ALV Grid control is based on the custom controls on the screen. When the program is scheduled in background, it tries to create GUI related front-end objects and hence the error u201CFatal Error u2013 GUI cannot be reachedu201D. This type of problem is common with all the programs that use the ALV grid control to display the output.
    Solution:
    Whenever we execute this type of programs in background, we should be passing a blank docking container instead of the custom container as parent to our grid control. 
    The docking container doesnu2019t need any of the custom controls on the screen; instead it attaches an area to any or all of the four edges of the screen (top, left, right or bottom). The behavior of the areas in the container is determined by the sequence in which they are initialized. Docking Containers are attached to the screen from the inside out. This means that when you create a second container, it is attached to the edge of the screen, and the container that was already there is pushed outwards. 
    Let us modify the standard program (by taking a copy of it) to enable it to execute it in background.
    Following modifications have to be made:
    ·        Define a docking container in the program
    data: or_doc  type ref to cl_gui_docking_container .
    ·        At the time of creating a custom container, check if the program is being executed in background or foreground. If the program is scheduled in background, then create a docking container instead of custom container.
    if cl_gui_alv_grid=>offline( ) is initial.
        create object or_custom_container
               exporting container_name = c_container.
      create object or_grid
             exporting i_parent = or_custom_container.
    else .
    create object or_grid
             exporting i_parent = or_doc .
    endif . 
    Now test executing the program in background. The report would be generated.

Maybe you are looking for

  • Can't display values from memory

    Hi, all experts i am having trouble displaying the value that i have imported to memory. EXPORT keyfgr           FROM  p_keyfgr     TO MEMORY ID 'CM_KEYFGR'. EXPORT fcst_filedata    FROM gt_fcst_filedata[]       TO MEMORY ID 'CM_FCST_FILEDATA'. SUBMI

  • Yosemite comments

    Yosemite downloaded in 2 tries.  Installed without a noticeable problem. Given the problems with Mavericks, the first thing I checked was my non-pages word processing programs.  No thesaurus support for word processing.  Another limitation created on

  • What is the use of at new statement?

    What is the use of at new statement?

  • Testing problems on Mac OS X 10.6.6 with CS5

    Hi, I installed Flash CS5 on my Mac but I have problems with testing movieclips. When I press CMD + Enter I get the Error: "Fehler beim Öffnen der URL 'file:////Volumes/myuser/.....file.swf'" When I publish the movieclip, all it's ok and I can watch

  • Compiling classes in their package structure

    I want to compile all classes using one command line I have the file structure. With .java files contained in two packages com.mine.FoldOne com.mine.FoldTwo so in the system C:/javaProj/src/com/mine/FoldTwo C:/javaProj/src/com/mine/FoldOne And the fo