Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4080464

missing repaint if drawing from a new thread in applet

XMLWordPrintable

    • sparc
    • solaris_2.5.1

      We have an applet that takes a long time (several minutes) to create its UI. We would like to be able to put up a busy cursor while the applet is loading. We
      tried starting off the UI creation in a new thread, but when this thread is
      done, the applet does not repaint itself, even when a repaint is invoked.
      Resizing or scrolling the applet does cause the repaint to occur.

      A test case follows. Uncommenting the join will cause the update to occur, but
      then the busy cursor is not shown. Please let the alias falcon-eng@emp know if
      there exist any workarounds. We have tried repaint(0), update, sync(), etc.

      import java.applet.Applet;
      import java.awt.Label;
      import java.awt.Cursor;

      public class AwtAsyncTest extends java.applet.Applet {

        public void init() {
          System.out.println("in init()");
          try {
            Thread.currentThread().sleep(5000);
          }
          catch (InterruptedException ex) {}
          System.out.println("exiting init()");
        }

        public void start() {
          System.out.println("in start()");
          Async async = new Async(this);
          async.start();
          /*
          try { async.join(); }
          catch (InterruptedException ex) {}
          */
          System.out.println("exiting start()");
        }

        public AwtAsyncTest() {
          System.out.println("in default constructor");
        }

        public AwtAsyncTest(java.applet.Applet app) {
          System.out.println("in constructor");
        }

        class Async extends Thread {
          Applet app;
          
          Async(Applet app) { this.app = app; }
          
          public void run() {
            app.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
            try {
              Thread.currentThread().sleep(5000);
            }
            catch (InterruptedException ex) {}
            app.setCursor(Cursor.getDefaultCursor());

            // BUG: "done" not shown
            Label label = new Label("done");
            app.add(label);
            app.repaint();
          }
        }
      }

            xdengsunw Xianfa Deng (Inactive)
            akhil Akhil Arora (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: