Block until repaint() completes ?

I am currently writing an applet targetted towards Java 1.1.8.
I am experiencing some display problems where VM does not redraw the screen promptly e.g. under heavy loads, or when running on a slow machine.
My 'engine' works as follows. A Timer wakes the engine every x ms which then redraws all sprites and calls repaint(). However if repaint() does not redraw the screen before the engine runs again, some sprites may have moved twice, or more. This means that the sprite may not be erased completely.
Is there anyway I can block until I know for sure that the screen has been repainted ?

My 'engine' works as follows. A Timer wakes the engine
every x ms which then redraws all sprites and calls
repaint(). However if repaint() does not redraw the
screen before the engine runs again, some sprites may
have moved twice, or more. This means that the sprite
may not be erased completely.I modified my code so that sprites are updated only when called from repaint()->update().
This fixed the problem.

Similar Messages

  • Does SelectableChannel.register block until Selector.select completes

    Hey all,
    Quick question. If I have 2 threads and I am trying to register a SocketChannel with a selector from one, and the other is currently in a selection operation. Does the registering operation block until the select operation finishes?
    i.e. The below appears to block indefinitely. Is this behavior avoidable, or do I need to force a selector wake-up to finish registering?
    public class RegisterLock {
         * @param args
        public static void main(String[] args) throws Exception {
            ServerSocketBinder binder = new ServerSocketBinder(false);
            final ServerSocket server = binder.acquireServerSocket();
            final ServerSocketChannel serverSocket = binder.acquireServerSocketChannel();
            serverSocket.configureBlocking(false);
            final Selector sel = Selector.open();
            serverSocket.register(sel, SelectionKey.OP_ACCEPT);
            Thread t = new Thread(new Runnable() {
                public void run() {
                    try {
                        Thread.sleep(5000);
                    } catch (InterruptedException e) { }
                    try {
                        SocketChannel socket = SocketChannel.open();
                        socket.configureBlocking(false);
                        socket.connect(new InetSocketAddress(server.getInetAddress(), server.getLocalPort()));
                        System.out.println("Registering socket with selector...");
                        socket.register(sel, SelectionKey.OP_CONNECT);
                        System.out.println("Successfully registered socket with selector.");
                        System.exit(0);
                    } catch (IOException e) { }
            t.start();
            System.out.println("Beginning select operation");
            sel.select();
    }

    Yes. Both operations synchronize on the same data structure. There are three answers:
    (a) selector.wakeup() before registering. Ensure your select() loop copes correctly with a selection result of zero, i.e. just does background operations and continues, doesn't treat it as a failure
    (b) Use a short selection timeout. Same remarks apply
    (c) use a queue of pending registrations and do all registration operations in the select() loop/thread.

  • "OpenDocument()" blocked until other report returns

    <p>Hello,</p><p> I am making a component in a J2EE application to view Web Intelligence reports. I built it around a sample from BO website, and everything was going just fine, until I faced a strange error. If you could help me with it, I would be very grateful.</p><p> <strong>Error scenario:</strong> I open a report from the application, enter the values for the prompts, and press "Run Query". While waiting for the query to return, I try to open another report through the application, but the report does not open until the first one has returned!</p><p> <strong>Alternate scenarios:</strong> the error does not happen in any alternate scenario. If I open the 2nd report before pressing "Run Query" in the first one, it opens fine. I did not see this error in any scenario other than the one outline above.</p><p> <strong>Implementation Notes:</strong> I wrote my component as to make one log on for the whole application (using one user session until it expires, and then logging on again). I guess this has something to do with my error.</p><p> <strong>My analysis:</strong> I didn&#39;t try to debug in it, but it seems to me that the method "ReportEngine.openDocument(int)" blocks until the first report returns. It seems that this is somehow related to having one user session, as I tried to make a similar scenario, but opening the 2nd report from the InfoView, effectively making it from another session (but using the same user). The report opened from the InfoView fine. I tried to open two reports from the InfoView, but I noticed that right-click was disabled. I had to open a new window and make a new logon to open another report, which made me think this is probably my problem.</p><p> <strong>My suggestions:</strong> If my analysis is correct, then I need to make a separate logon session with BO for every user of my application. In the extreme case, I would have to make a separate logon session for every report opened through my application. I would need that latter case if I&#39;m going to allow the user to simply open two reports in two windows (e.g. by right-clicking a link and choosing "Open in new window").</p><p> I wonder whether my analysis is correct, and if so, whether my suggested solution is the one I should do.</p><p> Could you please help me with this issue? I&#39;d be really thankful.</p><p> Good luck everyone.</p>

    When I have been experiencing the problem I have described, there have always been at least three reports being called within a second of each other, many cases five or more within a second.
    Knowing that there is a limit of three concurrent jobs could explain why a report would not run, however should a report job never return if it is there is no license available? At worst I'd expect it to throw an error, which is handled and logged.
    We are now trying to invoke the thread slightly different to allow only one report to run at a time. So far it seems fairly lousy for performance, but I haven't seen that lockup yet.
    I'm going to look into using ReportDocument.GetConcurrentUsage() also, however the problem with that is a deployment issue. We have hundreds of report dll's that would need to be changed - then we would have to get the people in the field to update to the new reports. I'd rather fix it at the application level as we have much greater control of the updating of the application.

  • Process exec() blocking until program terminates.

    My basic problem is that I am running a second application (someone elses .exe file) that just outputs broadcast messages it receives, line by line. The program is supposed to run indefinitely, and my app is supposed to parse each line that comes through....The issue I've encountered is that the Buffer seems to block until I close the Java App (which then terminates the exe process as well) and then the Buffer clears out on to the screen. The craziest part of this all, is that I had this working perfectly, and I have no idea what code modification I made that unveiled this issue. Here is the code in quesiton....
    Thanks.
    -avidan
    try {  
         // Start up the stdout application written by DSS. This application is constantly outputting text.....
         String cmdline = "C:\\Program Files\\TheProgram\\ConstantlyOutputing.exe";
         Process DSSProcess = Runtime.getRuntime().exec(cmdline);
         System.out.println("Started DSS App....");     
         // the bufferedreader that processes the DSS application output
         BufferedReader in = new BufferedReader(new InputStreamReader(DSSProcess.getInputStream()));
         // while there is output from the DSS application
         while( (DSSinput = in.readLine()) != null)
         System.out.println("Output: " + DSSinput);
         } // end of for loop for while (in.readline)
         DSSProcess.waitFor();
         in.close();
    } catch (Exception e) {
         System.out.println(e.toString());          
    } //end catch     

    actually. a side problem now occurs. because the
    readLine causes the thread to block, i am unable to
    continue execution on my other threads...do you have
    any ideas Yes, you have to create a new thread, something like this:
    class MyThreadToStartProcessReadInputAndWaitEndOfProcess extends Thread {
    public void run() {
    try {
    // Start up the stdout application written by DSS. This application is constantly outputting text.....
    String cmdline = "C:\\Program Files\\TheProgram\\ConstantlyOutputing.exe";
    Process DSSProcess = Runtime.getRuntime().exec(cmdline);
    } catch (Exception e) {
    System.out.println(e.toString());
    } //end catch
    MyThreadToStartProcessReadInputAndWaitEndOfProcess t = new MyThreadToStartProcessReadInputAndWaitEndOfProcess ();
    t.start();
    ...[next operations]
    (dont worry, ill give you all the duke
    dollars anyway)...Oh yes ! ;-)
    Xavier

  • Airport Extreme 802.11n Base Station blocking RealPlayer 11 completely

    I am trying to play this radio station (just a brasillian sports channel) on RealPlayer 11:
    rtsp://real.rbsonline.com.br/liverbs/*/broadcast/rdgaucha/gaucha.rm
    Which is completely blocked on my Airport Extreme 802.11n Base Station with the latest firmware update.
    It even blocks when RealPlayer is configured for HTTP only.
    I am using it on my iMac which is connected directly via a ethernet cable instead of wifi to the Airport Extreme 802.11n Base Station.
    RealPlayer can play it fine when I plug my iMac directly to the cable modem so it proves is the router. I never had RealPlayer issues before when I was using a linksys router.
    It does really feel like Apple put an intentional block on RealPlayer to stop competition.
    Anyone seen this issue? Guess it is related with the BBC RealPlayer issue.

    Fixed myself, problem was because I setup OpenDNS on base station, removed it now works

  • How to create modal dialog to suspend menu activity until process completes

    I have a Swing application with several tabs, buttons, and menu items.
    When the user pushes some of the buttons, a background process is kicked off that may take some time to complete.
    When the process is finished, I get notification from a socket that the process has completed.
    I then display a dialog that notifies the user that the process has completed.
    All this is in place.
    What I need to do is to block the user from pushing any other buttons, selecting tabs or menu items while the process is in progress.
    My thought was to display a modal dialog with a message and no buttons to remove it,
    and then have the application dispose the dialog when I get the completion response.
    Is there a way to do this with a JOptionPane or some variant or do I need to create a modal dialog from scratch?
    Any suggestions?

    I was playing around with this a bit and I think it can be done.
    In the main class of my application, I have a variable
    public JFrame mainFrame;
    mainFrame = this.getFrame():
    In the page where I want to disable the application, I have the following:
    parent.mainFrame.setEnabled(false);
    (parent is a reference to the main class)
    When I get a response back from the socket, I can set
    parent.mainFrame.setEnabled(true);
    This seems to do what I want, but the fly in the ointment is that it disables the entire application.
    If I don't get a response, then the application is hung.
    Can't use the "X" button to close the application.
    I think I can work on some refinements from the clues given to make it work.
    Thanks for the feedback.

  • HT1420 De-authorization being blocked until Feb 2013

    Two of our laptops were stolen and I want to deauthorize them and authorize the two new ones I just bought.  But iTunes is telling me I can't do it until Feb 2013.  Suggestions?

    Contact itunes support and ask for an exception.

  • HT1923 My i phone was slow, so i tried to restore it back to default, but it gave me an error, now i can't use it until it completely restore, what can i do?

    My phone was slow, so i tried to restore it back to it's original setting but there was an error.  Now, i can't use it until it can restore.  What can i do?

    Sounds like your phone was previously jailbroken.

  • I have created a card. When purchasing I am told that text/photo blocks still need completing; stopping my purchase.  These blocks must be on the rear of the Christmas Stitching card template that I cannot see/access on my screen  any ideas most welscreen

    I have created a card but when trying to purchase am told that text/photo boxes are still to be completed - stopping my purchase.  Ivan only presume these boxes are on the rear face of the card which I cannot see. Any comments or suggestions would've greatly appreciated urgently as this is my christmas card!!!  Many thanks

    Setting Lightroom's preview size to larger than screen resolution is guaranteed to slow things down. I have a dual monitor system whith Lightroom showing the loupe on one screen and the grid on the other. The screen sizes are 1920x1080 and 2560x1440. Following your practice for previews would bring my system to a crawl and I have an entry level workstation.All my previews are of standard 1024x768 in size. The only delays in viewing come when Lightroom is asked to display an image where there is no preview. Once the preview has been created, browsing is near instantaneous.
    I beg to differ! The reason is that a preview can be used for any size, which is smaller than that of the preview. Scaling down a preview can be done with little or not loss in quality compared to getting the full resulution and scale that down. Scaling up is not possible.
    In your case, you will not use the previews of 1024x768 at all for full screen display. Instead you will force L3 to create bigger previews the first time you open the photo. You could try this by generating the standard previews for new imported photos before you start browsing. Then try to browse. You will probably get the "Loading" message, which indicates that the preview was not used and another one with higher resolution will be made. Then try the same experiment, setting the size of the standard preview to 2048. If, and only if, the size of your display area is not more than 2048 pixels wide and you display a photo in lanscape orientation, you will be able to browse without delay after generating the standard previews.
    If I understand your setup correctly, you display the photos in a window of 2560x1440 pixels. I suspect that only 1:1 previews could be used for that. I think Adobe should increase the maximum size of the previews to a value larger than 2048, so that you are not forced to use only the 1:1 previews.
    I agree, that when the previews have been generated, browsing is near instantaneous.

  • Error -- Block Diagram is Completely Black

    Hello,
    I've been working on a relatively complicated .vi that has a good amount of case structures and flat sequences.  As I was testing the front panel and going back and forth between the block diagram, the block diagram became entirely black -- all I see is a black background -- no wires, blocks, etc.  I am still able to add blocks through the menu but can't actually see them being placed or anything.  Is there a way to fix this, or revert back to normal?  I would really not like to redo all this work...
    Thanks,
    Bryan 

    I think there are some unusal observations of you exceed a certain diagram size ( e.g. 16000 (?) in pixels). How big is your diagram?
    (Other possibilites are issues with your video card, graphics driver, or color depth setting of the OS.)
    LabVIEW Champion . Do more with less code and in less time .

  • Asset Download in Market has to wait until CC Complete Sync

    Hello,
    If I´m uploading a big PSD file to CC Files and try to download a Market Asset I have to wait until the big file upload to download a 2~3kb files. There´s another way? I sometimes pause the Sync and start again and that works but not always. You should fix that. Perhaps a parallel download pipe or something for Market assets.
    Thanks in advance.

    Hello,
    If I´m uploading a big PSD file to CC Files and try to download a Market Asset I have to wait until the big file upload to download a 2~3kb files. There´s another way? I sometimes pause the Sync and start again and that works but not always. You should fix that. Perhaps a parallel download pipe or something for Market assets.
    Thanks in advance.

  • Whar happened to my adblock. All ads were blocked until I sent you money last week!!

    before you updated the system and gave me a new "front page", requesting $3 (I sent $30), almost all ads were blocked from showing. This was the major reason for choosing Firefox in the first place. NOw, every time I open my computer, that same message appears, and all kinds of ads have begun appearing on my computer. I don't think any adblocker is doing it's job.

    Who did you specifically send the $30 to as neither Mozilla nor the Firefox browser charges you for Anything. What was the link?
    All you did was make somebody or a company $30 richer unfortunately.
    There is no new frontpage or rather homepage from Mozilla as the default homepage is '''about:home''' ever since Firefox 4.0

  • When the iPad makes up about icloud, the dialog box remains locked on the screen of the block until it ends up?

    What should I do?

    Reboot the iPad by holding down on the sleep and home buttons at the same time for about 10-15 seconds until the Apple Logo appears - ignore the red slider if it appears on the screen - let go of the buttons. Let the iPad start up.

  • Disable Navigation until Audio Completes?

    Is there a way to disable the 'forward' button (grey it out ideally) for each slide until the audio?
    Thanks,
    J

    There's no built-in way to do this to the Forward button on the playbar with standard Captivate functionality.
    If you want this level of control, you need to NOT use the playbar and have Forward buttons appear on slide when the audio finishes.

  • Parent not finished until children complete - stops new job from starting

    Is there anyway that we can 'de-link' 'disassocaite' - some method that we can start a new job again - even though children of a previous job are still active.
    This is causing quite a problem in our system whereby we need to start another background job of the same but the status is still active due to children...

    Thank you Gerben, more useful insights.
    I have had a respone from Simon whom is technical resource for CPS.
    "What Gerben was suggesting was that you simply have multiple scheduled occurences of the same job, which wouldn't really work either since you could end up with at least two jobs running at the same time. e.g while you could schedule two jobs to run every ten minutes but stagger the start time so they are 5 mins apart you are still contrained by how long the whole process takes before another is scheduled.  If you add more jobs then the frequency of the jobs are likely to coincide with other jobs which could lead to duplicate postings (something that has already happened).
    Regards,
    Simon"
    Edited by: Steve Coupland on Dec 2, 2010 7:38 PM
    This question has now been answered...It looks very promising as a fix on the CPS side - as opposed to having to code an fix on the SAP end - which is the best solution for this particular problem. Thanks to all whom contributed.
    Simon does point out an important fact that you actually will have multiple jobs running at the same time. But that is what you are looking for: you want to run the next job before the previous childs are finished.
    To disable the fact that CPS waits for child jobs, you need to set (you may need to add it first) the parameter WAIT_FOR_CHILD_JOBS on your copy of SAP_AbapRun to "N".
    So you can choose for each job if you want it to wait for child jobs. As Simon pointed out, for most cases you do, but in your particular situation you may want to deviate from the default behavior, and that can be done using the above mentioned parameter.
    Hope this helps,
    Anton Goselink
    Principal Consultant
    Redwood Software

Maybe you are looking for