How do I give the program time to write to a JTextArea field

Hi,
I created a swing application which listens for user input with a simple button that starts a whole process of reading database records, looping the records, writing files to a file system etc.
What I would like to do, is to present the user of the application with regular feedback on how far the program is in the overall execution of this big task.
something like:
- file a.pdf moved
- file b.gif moved
etc..
I write these line of text to a JTextArea control in my main panel.
I know the routines work, as feedback from the other controls are posted without problems in the JTextArea.
In a previous life (...those days) I did some work with .Net, and with something similar I learned that sometimes the application needs some time to "catch up" to be able to write to an UI component, by sleeping the thread for a second after each pass.
However, Thread.sleep(1000) does not seem to do the trick in my swing app.
Any ideas on how to do this?
Thanks,
-Rogier

JTextArea.append() is a thread-safe method, so you can call it and java thread scheduling will do everything for you
I'm not sure what you mean by "catch up", if your GUI stays responsive during your long job, than textArea will be updated.
public void runVeryLongJob(){
      for(int i=0;i<numOfTasksInLongJob;i++){
           doStuff(i);
           //update JTextArea     
       yourTextArea.append("Task "+i+" done");
}ok...camickr already answere this.. of course you have to be in separate thread for long job

Similar Messages

  • How can we let the program run in backgroud automatically?

    normally,we need to find peak off time run big program
    that read pooled table and slowly.
    How can we let the program run in backgroud automatically?
    BTW:before that pop a window just give runner a notice.

    Here is an example, try this one.
    REPORT ztest.
    PARAMETERS: p_vbeln LIKE vbak-vbeln,
                p_bkrun NO-DISPLAY.
    DATA: ls_vbak LIKE vbak.
    DATA: v_answer,
          v_jobcount LIKE tbtcjob-jobcount.
      IF p_bkrun IS INITIAL.
    *-- not background processing
        CALL FUNCTION 'POPUP_TO_CONFIRM_STEP'
             EXPORTING
                  textline1      = 'This may time out.'
                  textline2      = 'Do you want to run in background?'
                  titel          = 'Warning!!!'
                  cancel_display = space
             IMPORTING
                  answer         = v_answer.
        IF v_answer = 'J'.
    *-- run in the background
          CALL FUNCTION 'JOB_OPEN'
               EXPORTING
                    jobname          = 'ZTEST'
               IMPORTING
                    jobcount         = v_jobcount
               EXCEPTIONS
                    cant_create_job  = 1
                    invalid_job_data = 2
                    jobname_missing  = 3
                    OTHERS           = 4.
          IF sy-subrc <> 0.
            MESSAGE ID sy-msgid TYPE 'E' NUMBER sy-msgno
                    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
            EXIT.
          ENDIF.
    *-- submit the program in the background
          SUBMIT ztest
            WITH p_bkrun = 'X'
            WITH p_vbeln = p_vbeln
            USER sy-uname
            VIA JOB 'ZTEST' NUMBER v_jobcount AND RETURN.
    *-- close the job
          CALL FUNCTION 'JOB_CLOSE'
               EXPORTING
                    jobcount             = v_jobcount
                    jobname              = 'ZTEST'
                    strtimmed            = 'X'
               EXCEPTIONS
                    cant_start_immediate = 1
                    invalid_startdate    = 2
                    jobname_missing      = 3
                    job_close_failed     = 4
                    job_nosteps          = 5
                    job_notex            = 6
                    lock_failed          = 7
                    OTHERS               = 8.
          IF sy-subrc <> 0.
            MESSAGE ID sy-msgid TYPE 'W' NUMBER sy-msgno
                    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
          ENDIF.
          EXIT.
        ELSE.
          CLEAR v_answer.
        ENDIF.
      ENDIF.
      CHECK v_answer IS INITIAL.
      SELECT SINGLE * FROM vbak
                      INTO ls_vbak
                     WHERE vbeln = p_vbeln.
      IF sy-subrc <> 0.
        WRITE:/ 'Invalid Order Id.'.
      ENDIF.
    END-OF-SELECTION.
      CHECK v_answer IS INITIAL.
      IF p_bkrun IS INITIAL.
        WRITE:/ 'Here is the result running the program in foreground.'.
      ELSE.
        WRITE:/ 'Here is the result running the program in background.'.
      ENDIF.
      WRITE:/ ls_vbak-vbeln,
              ls_vbak-vkorg.

  • How can I get the elapse time for execution of a Query for a session

    Hi ,
    How can I get the elapse time for execution of a Query for a session?
    Example - I have a report based on the procedure ,when the user execute that it takes say 3 min. to return rows.
    Is there any possible way to capture this session info. for this particular execution of query along with it's execution elapse time?
    Thanks in advance.

    Hi
    You can use the dbms_utility.get_time tool (gives binary_integer type value).
    1/ Initialize you time and date of beginning :
    v_beginTime := dbms_utility.get_time ;
    2/ Run you procedure...
    3/ Get end-time with :
    v_endTime := dbms_utility.get_time ;
    4/ Thus, calculate elapsed time by difference :
    v_elapsTime := v_endTime - v_beginTime ;
    This will give you time elapsed in of 100th of seconds...
    Then you can format you result to give correct print time.
    Hope it will help you.
    AL

  • How can i use the airport time capsule as a external hard drive?

    how can i use the airport time capsule as a external hard drive?

    Why do you recommend not place things like iTunes libraries or photo libraries on the drive? It was what I am looking for...
    I suggest that you ask the experts over in the iPhoto Support Community about their opinions on placing an iPhoto or Aperture library on the Time Capsule....even if you plan to use a wired connection for your Mac and the Time Capsule.
    But, if Terrence Devlin answers, be prepared for a lecture about why you should not ever do this.
    If you place the iTunes library on the Time Capsule, be prepared for iTunes to give you messages about not being able to find the library.
    In addtion, LaPastenague has the answer for you in a nutshell......corruption problems.
    Bottom line....the Time Capsule is for your backups.....not "everyday" files and especially not libraries.

  • How we can give the confirmation of the sales order to the customer.?

    how we can give the confirmation of the sales order to the customer.?
    after the we generate thge sales order how we will give the confirmation to the customer automatically or in any way in SAP SD

    A confirmation can be given to the Sold to party for the sales order by means of an output type, which is the  most used functionality.
    You can create an output which can be a word or PDF document, or an email , fax etc. Based on the kind of confirmation you want to give (Document, email, fax) do corresponding settings in the output for printers, email settings, fax settings etc. and enable this output to be triggered during sales order creation by assigning the output to output procedure for sales documents. This part of configuring an output is done by Functional team while the email, fax settings are done by basis team in combination with tech team.
    The output should have a smartform and corresponding report program to populate the smartform. This part should be taken care of by the technical team.
    Once all these things are done, if a sales order is created, the output will be triggered which will send a confirmation document, email , fax as per the configuration to the sold to party. If you want the confirmation to be send to more partner functions, that is also configurable in the output configuration.
    Pls reward points if it helps.

  • Just imported clips and edited as new project. closed imovie. came back later and the entire project was gone. i was not done so i did not finalize it. how do i get the program to keep my project in progress

    running imovie on a powermac w 10.6.8. went through the tutorials. imported my clips, got the hang of basic editing, and created a project.
    was pretty happy with it, but needed to shut down and come back to work on it later. when i did come back, the entire project was gone.
    how do i get the program to save my work in progress, without finalizing it?
    thanks

    So, everything worked out just fine!
    I have all my material in the ProRes Codec on a seperate drive now. The project itself was kept or rather duplicated, the bin structure etc stayed the same but is linking to the newly created files. The playback and workflow is fluent. I am happy! 
    Time info: For about 120 GB of material the codec change process took 25 hours.
    Thanks for your help!
    Best
    *a

  • No yellow bar comes up when trying to allow adobe flash reader so how do I allow the program to be downloaded?

    The instructions for downloading Adobe flash reader state that a yellow bar will appear int he tool bars and just click allow. No yellow bar appeared so I could not figure out how to download the program. How do I allow the program to be downloaded?
    == This happened ==
    Every time Firefox opened

    The instructions on the Adobe site are out-of -date and do not apply to current versions of Firefox. Use the following instructions to install or update Adobe Flash.
    <u>'''Install/Update Adobe Flash Player for Firefox'''</u>: your ver. N/A; current ver. 10.0 r45
    See: '''[http://support.mozilla.com/en-US/kb/Managing+the+Flash+plugin#Updating_Flash Updating Flash]'''
    -'''<u>use Firefox to download</u>''' and <u>'''SAVE to your hard drive'''</u> (save to Desktop for easy access)
    -exit Firefox (File > Exit)
    -double-click on the Adobe Flash installer you just downloaded to install it
    -when the Flash installation is complete, start Firefox, and test the Flash installation here: http://kb.adobe.com/selfservice/viewContent.do?externalId=tn_15507&sliceId=1
    *<u>'''NOTE: On Vista and Windows 7'''</u> you may need to run the plugin installer as Administrator by starting the installer via the right-click context menu if you do not get an UAC prompt to ask for permission to continue (i.e nothing seems to happen). See this: http://vistasupport.mvps.org/run_as_administrator.htm
    *'''<u>NOTE for IE:</u>''' Firefox and most other browsers use a Plugin. IE uses an ActiveX version of Flash. To install/update the IE ActiveX Adobe Flash Player, same instructions as above, except use IE to download the ActiveX Flash installer.
    Also see:
    http://kb.mozillazine.org/Flash
    [[How do I edit options to add Adobe to the list of allowed sites]]
    <u>'''''Other Issues''''': to correct security/stability issues</u>
    <u>'''Update Java'''</u>: your ver. 1.6.0.17; current ver. 1.6.0.20 (<u>important security update 04-15-2010</u>)
    (Firefox 3.6 and above requires Java 1.6.0.10 and above; see: http://support.mozilla.com/en-US/kb/Java-related+issues#Java_does_not_work_in_Firefox_3_6)
    ''(Windows users: Do the manual update; very easy.)''
    See: '''[http://support.mozilla.com/en-US/kb/Using+the+Java+plugin+with+Firefox#Updates Updating Java]'''
    Do the update with Firefox closed.

  • How do you make the program start?

    I have installed PSE 11 twice, now; the second time after an uninstallation of the first installation.  Both times, the program started immediately FROM the installation.  After exiting from the program, I have not been able to restart the program.  I click on it; I double click on it (which should start 2 copies of the program!); I right click and click Open; I right click and click "open as administrator".  Absolutely NOTHING happens.  Is there some sort of glitch that means you have to leave the program open permanently?  Please, how do I open the program? 
    Thank you.
    Cherie Brumfield

    Thanks so much for responding.  As it happens, I had already tried that
    approach, with no results.  I also spent some time last evening with a tech
    on the Adobe Chat page, also with no results.  So I just reloaded my PSE 8
    program, which does still work!  And this morning I get a notice of an
    Adobe update to PSE 11 and, guess what?!--NOW PSE 11 works just fine!!  Go
    figure!
    All of which has nothing to do with you having responded to my plea for
    help.  I really appreciate someone responding; it's nice to know that
    people "out there" really do care.  Thank you.
    Cherie
    On Wed, Feb 6, 2013 at 4:55 AM, bridge_mastero

  • How can i request the actual time code of digital video recorder, i am using RS232 interface for asking actual time code of digital video recording

    how can i request the actual time code of digital video recorder, i am using RS232 interface for asking actual time code of digital video recording

    If you have an RS-232 interface to the digital video recorder, it may be that you can send a command to the video recorder in order to get the time code sent back to your application - you would then read this as a string and then incorporate this data into your program.
    The best source of help will be any documentation you have relating to the serial (RS-232) interface with the digital video recorder. This documentation should have commands that you can send to the recorder and expected response strings that you should get back from the device. This task should be straightforward but can often be frustrating without documentation about the video recorder. This will not be something that you can "guess" - past experience in writing serial communication ap
    plications has shown that a good manual is your best friend.
    Failing this if you have any source code for example programs that have already been written to communicate with the recorder, you might be able to extract the relevant ASCII strings and use them within your application. This is true whether you are using LabVIEW or a text-based language.
    Jeremy

  • SL:How do I give the Admin account premissions to access other accounts?

    How do I give the Admin account the permissions needed to read and write the folders desired in the other account(s)?

    hassiman wrote:
    I have a MacPro running Tiger and for whatever reason when I am logged into the machine with my user account which has Admin privilages I can open/drag and drop etc. from my desktop to my wife's account ( which I set up as limited with parental restriction to only what she needs to access and use.)
    a parental controlled account for your wife. you must have an interesting relationship...
    I am setting up a Mac Mini running SL for my 90 year old in-laws and it was my intention to give them a STANDARD user account so that they can not download and install anything nasty which they did all the time on the Windoze machine the Mini is replacing. I have set up an Admin account on the machine so I can install stuff and perform maintenance functions VIA VNC connection from San Dieg to them in NYC... But I was surprised when I could not access any folders on their account... specifically their desktop where I tried to drop a file.
    Not sure why it's no biggie on Tiger but Leopard's throwing a fit. Any ideas?
    this is quite normal and is the default in all versions of OS X. a user has write access too their own home directory but not to any other users home directories. being an admin user does not change that. as an admin user you can give yourself write writes to it as discussed earlier but that won't happen by default. the best thing to do in the situation you describe is to log in as your in-laws once you vnc into their computer. then you can copy what you need to the desktop. it's of course possible to do it from the admin account by giving it write access to their desktop as you were intending but that will give you extra problems later because their users won't have write privileges to anything you copy that way.

  • How can we give the Data Format (File Type ) in Runtime

    Hi all,
    How can we give the Data Format (File Type ) in Runtime for the following method,
    cl_gui_frontend_services=>gui_download.
    Thanks in advance
    Sri

    There is a filetype parameter which you can set
    CALL METHOD cl_gui_frontend_services=>gui_download
      EXPORTING
    *    BIN_FILESIZE              =
        filename                  =
    *    FILETYPE                  = 'ASC'
    *    APPEND                    = SPACE
    *    WRITE_FIELD_SEPARATOR     = SPACE
    *    HEADER                    = '00'
    *    TRUNC_TRAILING_BLANKS     = SPACE
    *    WRITE_LF                  = 'X'
    *    COL_SELECT                = SPACE
    *    COL_SELECT_MASK           = SPACE
    *    DAT_MODE                  = SPACE
    *    CONFIRM_OVERWRITE         = SPACE
    *    NO_AUTH_CHECK             = SPACE
    *    CODEPAGE                  = SPACE
    *    IGNORE_CERR               = ABAP_TRUE
    *    REPLACEMENT               = '#'
    *    WRITE_BOM                 = SPACE
    *    TRUNC_TRAILING_BLANKS_EOL = 'X'
    *  IMPORTING
    *    FILELENGTH                =
      changing
        data_tab                  =
    *  EXCEPTIONS
    *    FILE_WRITE_ERROR          = 1
    *    NO_BATCH                  = 2
    *    GUI_REFUSE_FILETRANSFER   = 3
    *    INVALID_TYPE              = 4
    *    NO_AUTHORITY              = 5
    *    UNKNOWN_ERROR             = 6
    *    HEADER_NOT_ALLOWED        = 7
    *    SEPARATOR_NOT_ALLOWED     = 8
    *    FILESIZE_NOT_ALLOWED      = 9
    *    HEADER_TOO_LONG           = 10
    *    DP_ERROR_CREATE           = 11
    *    DP_ERROR_SEND             = 12
    *    DP_ERROR_WRITE            = 13
    *    UNKNOWN_DP_ERROR          = 14
    *    ACCESS_DENIED             = 15
    *    DP_OUT_OF_MEMORY          = 16
    *    DISK_FULL                 = 17
    *    DP_TIMEOUT                = 18
    *    FILE_NOT_FOUND            = 19
    *    DATAPROVIDER_EXCEPTION    = 20
    *    CONTROL_FLUSH_ERROR       = 21
    *    NOT_SUPPORTED_BY_GUI      = 22
    *    ERROR_NO_GUI              = 23
    *    others                    = 24

  • On my HP Touchsmart 310 PC how do I increase the inactivity time on the display?

    On my HP Touchsmart 310 PC how do I increase the inactivity time on the display?   Windows 7, 64-bit

    Hi,
    Please try Control panel > Power options > Change when the computer sleeps
    Hope this helps.
    BH
    **Click the KUDOS thumb up on the left to say 'Thanks'**
    Make it easier for other people to find solutions by marking a Reply 'Accept as Solution' if it solves your problem.

  • I would like to read a text file in which the decimal numbers are using dots instead of commas. Is there a way of converting this in labVIEW, or how can I get the program to enterpret the figures in the correct way?

    The program doest enterpret my figures from the text file in the correct way since the numbers contain dots instead of commas. Is there a way to fix this in labVIEW, or do I have to change the files before reading them in the program? Thanks beforehend!

    You must go in the labview option menu, you can select 'use the local
    separator' in the front side submenu (LV6i).
    If you use the "From Exponential/Fract/Eng" vi, you are able to select this
    opton (with a boolean) without changing the labview parameters.
    (sorry for my english)
    Lange Jerome
    FRANCE
    "Nina" a ecrit dans le message news:
    [email protected]..
    > I would like to read a text file in which the decimal numbers are
    > using dots instead of commas. Is there a way of converting this in
    > labVIEW, or how can I get the program to enterpret the figures in the
    > correct way?
    >
    > The program doest enterpret my figures from the text file in the
    > correct way since the numbers contain dots instea
    d of commas. Is there
    > a way to fix this in labVIEW, or do I have to change the files before
    > reading them in the program? Thanks beforehend!

  • How do I determine the # of times a song has been down loaded; 7 is max?

    How do I determine the # of times a song has been down loaded? Is 7 max?

    Jim, I apprecite your help. Im still  lost...not that efficient on computer. Some notes, If burn playlist to disc doesn appear in the menu, it means that the playlist you selected cant be burned to a CD because it contains items that have usage restrictions;  if the playist contains itunes store purchases that are not itune plus songs, you can burn the playlsit to a CD up to 7 times;  DRM - Digital Rights Management????  Any help is appreciated Thank You

  • I purchased creative cloud when I purchased my laptop, I've since had to put in a new hard drive.  How do I reinstall the programs on my new hard drive?

    I purchased creative cloud when I purchased my laptop, I've since had to put in a new hard drive.  How do I reinstall the programs on my new hard drive?

    Creative Cloud Help / Sign out, Sign in | Creative Cloud desktop app
    http://helpx.adobe.com/creative-cloud/kb/sign-in-out-creative-cloud-desktop-app.html
    Creative Cloud Help / Install, update, or uninstall apps
    http://helpx.adobe.com/creative-cloud/help/install-apps.html
    Installing Creative Cloud Apps
    http://tv.adobe.com/watch/cs6-creative-cloud-feature-tour-for-video/installing-desktop-app s-from-creative-cloud/

Maybe you are looking for