Of what use is SwingUtilities.invokeAndWait?

hi,
i have a GUI that processes a huge amount of data on each click of the button. By huge, i mean it processes
packs of about 1000 bytes each, but at any given time there could be 25,000,000 or more of them. Hence,
my application is very sensitive to slight shifts in processing speeds for each claim. An extra half a second processing any of these can lead to unacceptable processing times. 2 or 3 hours is OK, but 2 or 3 days is not. Anyways, each time I click on the button to process the process starts, and the GUI stops responding. I have been researching how to get this to stop and I, of course, came across the SwingUtilities.invokeAndWait() method. However, if I can't call it from the EventDispatch thread, of what use is it? I mean, the only time I need it is when a Button is pressed and I start processing data. Is there anything I can do to satisfy my need to maintain speed and a decent looking GUI? I tried calling this.paintAll(this.getGraphics()) a bunch of times, but that makes my screen flash and it seems to take forever and slow my app down way too much. Any ideas Swing gurus? thanks

Ok, so I took one of my shorter processes from my GUI and I put that into its own class that extends thread and I launched it from the eventDispatch thread (the actionPerformed function, i assume they are the same thing) however, my GUI is still not updating. What gives? I did launch a thread, so it seems like my GUI should be responsive. I know the thread was launched because it responds properly, but I still can't get the GUI part to work. Here is a sample of the code:
//here is how i call this...
     else if(E.getSource() == CheckRecordLengthButton){
           CheckForRecordLength CFRL = new CheckForRecordLength(ReferenceFileField.getText(),
                                                                                RFW.getRecordLength(), CheckRecordLengthButton);
       }//end else
//here is the actual class declaration...
class CheckForRecordLength extends Thread{
     String filepath;
     int RL;
     JButton Button;
     public CheckForRecordLength(String Filepath,int rL,JButton button){
                       //do constructor stuff...
     public void run(){
          try {
                          //...do some useful work...
          catch (Exception e) {
               // TODO Auto-generated catch block
               e.printStackTrace();
          }//end catch
     }//end function run
} //end class defso, is there a way to launch this thread and still get the GUI to update? I REALLY appreciate the help....

Similar Messages

  • A question about SwingUtilities.invokeAndWait

    I have this method in my program:
          * Execute the query and closes the dialog
         private void executeQueryAndClose() {
              String whereClause = (String) queryCbo.getSelectedItem();          
              List<JobFields> jobs = controller.getQueryResult(whereClause);
              controller.getEditWindow().getResultsPane().cleanResults();
              controller.getEditWindow().getResultsPane().displayResults(jobs);
              dispose();
         }this method executes a query to the db, display the results and closes
    the query dialog.
    This method is run in the event dispatcher thread.
    Now I was wondering if I should put the controller.getQueryResults in a different thread and run SwingUtilities.invokeAndWait with the new thread.
    I have to wait for the results from the db to return before I can display them,
    but I accomplish the same thing by running it the way written above.
    What's the difference between retrieving the results from the db in the event dispatcher thread and running them in a seperate thread and waiting for them to return by using invokeAndWait?
    In both ways I wait for the results from the db to return.

    I have this method in my program:
          * Execute the query and closes the dialog
         private void executeQueryAndClose() {
    String whereClause = (String)
    g) queryCbo.getSelectedItem();          
    List<JobFields> jobs =
    = controller.getQueryResult(whereClause);
              controller.getEditWindow().getResultsPane().cleanRes
    ults();
              controller.getEditWindow().getResultsPane().displayR
    esults(jobs);
              dispose();
         }this method executes a query to the db, display the
    results and closes
    the query dialog.
    This method is run in the event dispatcher thread.
    Now I was wondering if I should put the
    controller.getQueryResults in a different thread and
    run SwingUtilities.invokeAndWait with the new
    thread.
    I have to wait for the results from the db to return
    before I can display them,
    but I accomplish the same thing by running it the way
    written above.
    What's the difference between retrieving the results
    from the db in the event dispatcher thread and
    running them in a seperate thread and waiting for
    them to return by using invokeAndWait?
    In both ways I wait for the results from the db to
    return.If you do this work in the Event dispatch Thread, you will block all other event related activity from occurring. For example, if you press a button to retrieve the results, the button may seem stuck in the pressed position while the work occurs. This is one of the primary sources of 'preceived slowness' with Swing applications.
    The proper way to do this is the spawn a Thread to do the work, and then use invokeLater (not invokeAndWait) from this spawned Thread to update the UI. I created an example that exhibits the 'bad' and 'good' way to do this. See this post:
    http://forum.java.sun.com/thread.jspa?threadID=743510

  • Javax.swing.SwingUtilities.invokeAndWait limitation

    Hi all,
    I have the following method:
    private static void m() throws Throwable
    try {
          javax.swing.SwingUtilities.invokeAndWait ( new Runnable(){public void run(){
          try{
                invoke ( ... );                        // a Method.invoke() call
          } catch(Throwable t) {throw t;}
      } catch (Throwable th){}
    }If invoke() throws an exception, I need to pass the exception back to the caller of m(); however, I cannot do that since run() doesn't allow that
    Thank you

    Check the Javadoc, SwingUtilities.invokeAndWait(...) declares it can throw an InvocationtargetException that is just what you need.I knowYou didn't seem to, since you blamed an "invokeAndWait limitation" for a fact that is indeed with the Runnable interface.
    but the problem is with the invoke() call (inside the run()). I have to wrap it in a try - catch. What should I do with the caught exception ?Rethrow it wrapped in an unchecked exception?
    Note that if the exception thrown by Method.invoke() is already an InvocationTargetException, you may prefer to wrap this exception's cause instead, as the caller of invokeAndWait() will already have to unwrap it from an (+other+) InvocationTargetException.
    All that (cheating with checked/unchecked exceptions) is frowned upon in business code but is acceptable in framework code. If the caller of m() needs a strongly-typed exception handling interface, I suggest you wrap the nasty code so as to expose only the clean-cut interface.
    Note that Another practice that is questionable is a statement such as catch Throwable (except, again, in framework code). Regular business code shouldn't catch Errors.
    I suggest you read the Java tutorial's [chapter on exceptions|http://download.oracle.com/docs/cd/E17409_01/javase/tutorial/essential/exceptions/index.html] as well.
    Best regards.

  • What is a data group and what use is it for?

    CAn some one explain me the concept of data group in EBS. What is it used for ? How does it enhance the security of Oracle Apps data ?
    I know that Data groups are used while defining a responsibility and are meant for data security purpose. But I want to know the conceptual details behind it.
    Thanks.

    Ok.. so with a data group we can have data security at Oracle schema level. I hope my understanding is correct.
    I can create a data base user called Sinha and create a data group with this user/schema.
    Now when I create a data group with this schema and assign it to a responsibility, which in turn is assigned to a user, he/she will have access only to those objects which are present in the schema called Sinha, right ?
    Now as all the objects in Oracle Apps are created under the Apps schema, what use this new data group (and schema) is of ?

  • [svn] 3789: Integrated Build 192 of what used to be called TCAL (and, before that, Vellum).

    Revision: 3789
    Author: [email protected]
    Date: 2008-10-21 12:55:26 -0700 (Tue, 21 Oct 2008)
    Log Message:
    Integrated Build 192 of what used to be called TCAL (and, before that, Vellum).
    The Text Component ActionScript Library (TCAL) has been renamed to the Text Layout Framework. Its classes are now in the package flashx.textLayout rather than in flashx.tcal, and they are packaged into SWCs named textLayout_xxx.swc rather than tcal_xxx.swc. The XML namespace for importable markup is now "http://ns.adobe.com/textLayout/2008" rather than "http://ns.adobe.com/tcal/2008".
    QE Notes: Please update package names (and XML namespaces, if necessary) in all test files.
    Doc Notes: Please eliminate all references to "Text Component ActionScript Library" or "TCAL" and use "Text Layout Framework" instead.
    Bugs: -
    Reviewer: -
    Modified Paths:
    flex/sdk/trunk/build.xml
    flex/sdk/trunk/frameworks/fxg-manifest.xml
    flex/sdk/trunk/frameworks/mxml-2009-manifest.xml
    flex/sdk/trunk/frameworks/projects/flex4/build.xml
    flex/sdk/trunk/frameworks/projects/flex4/src/mx/components/FxTextInput.as
    flex/sdk/trunk/frameworks/projects/flex4/src/mx/components/TextView.as
    flex/sdk/trunk/frameworks/projects/flex4/src/mx/components/baseClasses/FxTextBase.as
    flex/sdk/trunk/frameworks/projects/flex4/src/mx/events/TextOperationEvent.as
    flex/sdk/trunk/frameworks/projects/flex4/src/mx/graphics/Parser.as
    flex/sdk/trunk/frameworks/projects/flex4/src/mx/graphics/TextGraphic.as
    flex/sdk/trunk/frameworks/projects/flex4/src/mx/graphics/graphicsClasses/TextFlowComposer .as
    flex/sdk/trunk/frameworks/projects/flex4/src/mx/utils/TextUtil.as
    flex/sdk/trunk/frameworks/projects/wireframe/build.xml
    Added Paths:
    flex/sdk/trunk/frameworks/libs/textLayout_conversion.swc
    flex/sdk/trunk/frameworks/libs/textLayout_core.swc
    flex/sdk/trunk/frameworks/libs/textLayout_edit.swc
    Removed Paths:
    flex/sdk/trunk/frameworks/libs/tcal_conversion.swc
    flex/sdk/trunk/frameworks/libs/tcal_core.swc
    flex/sdk/trunk/frameworks/libs/tcal_edit.swc

    Revision: 3789
    Author: [email protected]
    Date: 2008-10-21 12:55:26 -0700 (Tue, 21 Oct 2008)
    Log Message:
    Integrated Build 192 of what used to be called TCAL (and, before that, Vellum).
    The Text Component ActionScript Library (TCAL) has been renamed to the Text Layout Framework. Its classes are now in the package flashx.textLayout rather than in flashx.tcal, and they are packaged into SWCs named textLayout_xxx.swc rather than tcal_xxx.swc. The XML namespace for importable markup is now "http://ns.adobe.com/textLayout/2008" rather than "http://ns.adobe.com/tcal/2008".
    QE Notes: Please update package names (and XML namespaces, if necessary) in all test files.
    Doc Notes: Please eliminate all references to "Text Component ActionScript Library" or "TCAL" and use "Text Layout Framework" instead.
    Bugs: -
    Reviewer: -
    Modified Paths:
    flex/sdk/trunk/build.xml
    flex/sdk/trunk/frameworks/fxg-manifest.xml
    flex/sdk/trunk/frameworks/mxml-2009-manifest.xml
    flex/sdk/trunk/frameworks/projects/flex4/build.xml
    flex/sdk/trunk/frameworks/projects/flex4/src/mx/components/FxTextInput.as
    flex/sdk/trunk/frameworks/projects/flex4/src/mx/components/TextView.as
    flex/sdk/trunk/frameworks/projects/flex4/src/mx/components/baseClasses/FxTextBase.as
    flex/sdk/trunk/frameworks/projects/flex4/src/mx/events/TextOperationEvent.as
    flex/sdk/trunk/frameworks/projects/flex4/src/mx/graphics/Parser.as
    flex/sdk/trunk/frameworks/projects/flex4/src/mx/graphics/TextGraphic.as
    flex/sdk/trunk/frameworks/projects/flex4/src/mx/graphics/graphicsClasses/TextFlowComposer .as
    flex/sdk/trunk/frameworks/projects/flex4/src/mx/utils/TextUtil.as
    flex/sdk/trunk/frameworks/projects/wireframe/build.xml
    Added Paths:
    flex/sdk/trunk/frameworks/libs/textLayout_conversion.swc
    flex/sdk/trunk/frameworks/libs/textLayout_core.swc
    flex/sdk/trunk/frameworks/libs/textLayout_edit.swc
    Removed Paths:
    flex/sdk/trunk/frameworks/libs/tcal_conversion.swc
    flex/sdk/trunk/frameworks/libs/tcal_core.swc
    flex/sdk/trunk/frameworks/libs/tcal_edit.swc

  • I have an old ipod touch and use it everyday now i cant get on facebook and cant download apps which i want as it requires ios 4.3. what use is it to me anymore and are apple willing to do something about it

    i have an old ipod touch and use it everyday now i cant get on facebook and cant download apps which i want as it requires ios 4.3. what use is it to me anymore and are apple willing to do something about it

    Your only way is if you have the version that was compatible on your computer such as in the recycle bin/trash or in a computer file backup. In that case delete the current version that is in your iTunes App library and replace it with the older version. Then sync.

  • What uses less ink, plain paper fast draft, or photo paper best.

    What uses less ink, plain paper fast draft, or photo paper best.  I'm not looking for quality, just less ink used.  I also used photo paper, then selected plain paper fast draft.  Not great quality, as expected, but still looking to use less ink.  My guess is the plain paper uses more, because it is more porous. My printer is an hp Deskjet 2050.  My operating system is, 64-bit Intel Core I-7-2670 QM.
    Thank You for any assistance
    emt1d
    This question was solved.
    View Solution.

    The printer will put droplets of ink on the page based on what it detects the media is (for printers with "Automatic" as a paper type) or the specified media in the driver.
    If you select plain paper, draft and print on photo paper it would use the same amount of ink as if you put in plain paper.  The results are likely to be very very poor if you do that, for several reasons:
    The pigmented black ink is not compatible with photo paper, it will not dry properly.  When photo media is selected the printer will not use the pigmentd black ink even to print text, it will mix color to make black.
    It takes much more ink to give proper photo settings on photo paper as compared to plain paper.  Using plain paper draft settings is likely to result in an unusable photo paper page, ruining a $1 sheet of photo paper to save a $0.20 worth of ink - not a good tradeoff.
    If you plan to print a lot of photo's you might consider a printer that uses the HP Ink advantage subscription service.  This service is based on pages printed, and they count photo pages the same as plain paper, even though a full page photo may use 10x or more the ink of a plain paper text page.
    Bob Headrick,  HP Expert
    I am not an employee of HP, I am a volunteer posting here on my own time.
    If your problem is solved please click the "Accept as Solution" button ------------V
    If my answer was helpful please click the "Thumbs Up" to say "Thank You"--V

  • Purchased new iphone 4 yesterday and I already have used 73.81 MB of my 200 and I have not done much of anything. What uses mb ? does it use mb every time I play the game?  when I am reasding my emails does it use MB ?

    I purchased an IPhone 4 yesterday and I have already used 73.81 mb of my 200 mb. I have only read my emails and downloaded one game from App Store. Does it use MB everytime I play the game? does it use mb the whole time I am on my emails. What uses MB?

    Playing a game probably won't use much, if any... Downloading all those cool games and apps could have easily used that up, however.
    Use WiFi whenever you can or download apps to your computer, then sync them to the phone with the cable.

  • What use of having double precision in java.awt.geom?

    Hi,
    I am trying to draw a line using Line2D with this param:
    g2d.draw( new Line2D.Double( 1.1d, 1.5d, 1.9d, 1.5d ) );
    in my own JPanel paint method.
    However, the result is that the panel does not display a line nor a dot at all. Only when i change it to:
    g2d.draw( new Line2D.Double( 1.0d, 1.5d, 2.0d, 1.5d ) );
    that it draws a dot in the panel's first pixel.
    Can someone please guide or tell me why is this so? And what is the purpose of providing a double value for a geom ( such as Rentagle2D, Line2D, etc )?
    The actual case is that I have created a graph with x and y axis. I set the graph to be 400pixel * 400 pixels. And the scale for the graph is 1 million unit * 1 million unit which means a pixel would have contain (1000000/400) units, or 0.004 pixels represent 1 unit. The problem occurs when i try to draw a line that is only 10 unit.(which nothing is draw on the panel). I try to use all 2D geom with double precision, yet i could not get the result that I wanted. Isn't that java 2D will handle the double precision for graphing or drawing?
    Your help and reply is very much appreciated.
    Thank you.

    have in mind that you always have to fill 1 pixel to see anything as the panel has a 1 pixel grid.
    i guess the thing about double precision is in the contains(...) or crosses(...) methods of the geom.* objects.
    its nothing about drawing. how can you draw finer than the 1 pixel grid.
    even the antialias has to fill more pixel to make you thing the line is smooth. (BTW: antialias makes fonts widt less than 10px look terrible :))

  • Is there a way to have what used to be called "Macros" (a small blurb that you type repeatedly over and over)?

    Is there a way to have the use of what we used to call "Macros" which would be a key you could hit where you have installed a word, phrase, etc that you type repeatedly? By this I mean if, while on line, you repeatedly type out the phrase "Thank you very much for your attention to this matter"....you could hit a key (like maybe F5 or something similar) that would automatically type this phrase out so you don't have to type it over and over and over again.

    You can also look at Clippings.
    *Clippings: https://addons.mozilla.org/firefox/addon/clippings/

  • Whatis use of rfc

    1.what is use of rfc in sap.
    2.can u tell about asap phases in sap hr for implementation

    RFC: In all SAP systems, CALL FUNCTION represents an integral part of the ABAP language. This statement executes a function (a function module) in the same system.
    REMOTE FUNCTION CALL (RFC) is an extension of CALL FUNCTION in a distributed environment. Existing function modules can be executed using an RFC from a remote system. This is done by adding a DESTINATION clause to the CALL FUNCTION statement. The destination parameter displays an entry in the RFCDES table (which is defined with transaction SM59). This entry contains all necessary parameters to connect to and log in the destination system. 
    You can use RFC between two SAP systems.

  • What uses the most data on these phones

    My step daughter goes over her monthly data allowance every month, I'm not sure what she is doing that is using so much of the data, does anyone have any ideas

    The phone does not use data from your allowance if she is using wifi. Make sure she is logged on correctly.
    You may all be on FB and Instagram, but do you use it in the same fashion and as regularly as your daughter? You can both be on FB, but if she uses it for 3-4 hours and you use it for 30 minutes, the usage will not be the same. Do you use FB while riding school bus? Does your daughter? No wifi on school bus I would wager. Does your daughter watch videos posted on FB? If not on wifi at the time, that uses a LOT of data.
    Do you post as many photos on Instagram as your daughter? I know I certainly don't. Each of those photos use data to upload unless done so via wifi.
    You may ALL be on certain apps, but I doubt you use the app in the same fashion as a teenage daughter UNLESS you have gone over with her how she should be using it to stay within a set data limit.
    You asked for ideas on what could be using data. EACH of the apps I mentioned COULD be using data. Doesn't mean they are, it all depends on how the app is being used. Different people use apps differently. Simply because one person does not use data on an app does not mean another could be using a lot of data on the very same app.
    Other sources for large amounts of data usage would certainly be iTunes. Does she download music, podcasts, videos, etc... while using cellular data? That would consume a LOT of data.

  • Magic wand - What does it do, what use is it?

    Clicking with the magic wand tool 'selects' colours depending
    on the settings in the Trace tool dialogue, but to what purpose?
    I am not talking about dragging with the trace tool, which
    creates a vector trace depending on the settings in the Trace tool
    dialogue.

    P A H wrote:
    > Clicking with the magic wand tool 'selects' colours
    depending on the
    > settings in the Trace tool dialogue, but to what
    purpose?
    >
    > I am not talking about dragging with the trace tool,
    which creates a
    > vector trace depending on the settings in the Trace tool
    dialogue.
    >
    Well, look at that. I haven't really played around with the
    trace tool
    too much in the last few years but that is very interesting.
    Click once
    and it makes a selection based on the color under where you
    click. Click
    in that selection again and you get a new dialog box. If you
    select
    "trace" it does its usual trace function. But "convert to
    edge" gives
    you a vector shape in the form of the selection. That could
    be very
    useful. Thanks for sharing that!

  • Best settings for what used to be HDV, became M2V?

    I have some concert footage I shot in HDV60i (on a Canon HV40). I only exported it to DVD and not to an HDV file, so all I have now is an M2V file and an audio file (AAC). Now I need to upload it to youtube, but I have to do some editing in FCP6 first. What is the best sequence settings for me to use in FCP? My second question would be how should I export it for best viewing on youtube (since it's no longer a true HDV file), but that question may be better served for the Compressor forum...any info would be appreciated though!

    hi,
    well a lot depends on the footage you might be using. Use the setting that matches that. Or if its graphics based use the biggest baddest HD setting you can. Of course if the finished thing is getting burnt to a DVD to be shown its all going to be compressed then and lose quality at that stage.
    hth
    adam

  • What use of fb07

    What is difference between account assignment and account determination
    plz help me and what is the use of fb07

    Hello,
    Please check this link:
    Control Totals in FI Transactions
    REgards,
    REnan

Maybe you are looking for

  • Not able to find aliased tables when supplying username/password

    <p>I am able to run my report which contains several aliased tables just fine as long as I have the application (Viewer?) ask for the login credentials for the database. But it seems if I try to set the login credentials in the Viewer jsp, I then rec

  • How to track the cursor in the MODULE POOL?

    Hello everyone, I have developed one module pool program. I am facing a problem in tracking the cursor position. Let me tell you in detail. I have display/change button on the screen. If I come in change mode and gives a invalid value to any of the f

  • Issue with variables and white space in powershell script that calls a command line command

    Guys, I have a question regarding this script. Each time I run it, it creates the share, but with a space after it. Also I need help figuring out how to put in the variable for the folder path. Below is the code $Users=Import-Csv C:\users2.csv foreac

  • Online Skype Number for BKK, Thailand

    Hello, I residence in BKK, Thailand, but I am an American Citizen as well! I have a home in Boulder, Colorado. What is the best one for me to use Skype for my Samsung S3 Phone here in Thailand; where I actually lives most of the years?? Thank you for

  • How to find which type of extraction to be used

    Hello, Can any one help me out to find out which extraction type to be used in different situations. Thanks, Raghavendra.