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

A java.awt component calls paint() differently on different platforms

    XMLWordPrintable

    Details

    • Subcomponent:
    • CPU:
      x86
    • OS:
      windows_95

      Description



      Name: akC57697 Date: 05/08/97



      A java.awt component calls paint() differently on different platforms.
      The next test passes on Solaris without any stops in accordance with
      intuitive understanding, but hangs on Windows95.
      AWT documentation doesn't say anything about when to expect a paint()
      call and when not to expect it.

      ---------------------------Test.java--------------------------------------------
      import java.awt.*;

      public class Test {
         public static void main(String[] args){

            TestButton one;
            Frame f = new Frame();
            f.setSize(300,200); // set initial size
            one = new TestButton("TestButton");
            f.add(one);
            f.setVisible(true); // show container

            try {
              one.waitForPaint();
            }
            catch (InterruptedException e)
            { System.out.println("interrupted(1)");
              return ;
            }

            // Perform test several times
            for (int i=0; i<5; i++) {
              one.setLabel("Wait for repaint... N"+i); //setLabel must call paint()
              
              try {
                one.waitForPaint();
              }
              catch (InterruptedException e)
              { System.out.println("interrupted(1)");
                return ;
              }
              
      try {
                  Thread.sleep(500);
              } catch (InterruptedException e) {}
            }
             System.out.println("OKAY"); //No delays
               System.exit(0);
         }
      }

      class TestButton extends Button {
        private boolean sawPaint;

            TestButton() {
              super();
              sawPaint = true;
            }

            TestButton(String title) {
              super(title);
              sawPaint = true;
            }

            public void paint(Graphics g) {
              super.paint(g);
              synchronized(this) {
                sawPaint = true;
                notifyAll();
              }
            }

            public synchronized void waitForPaint() throws InterruptedException {
              sawPaint = false;
              while (sawPaint == false) {
                wait();
              }
            }

      }

      ______________________ Output ________________________________________
      Solaris:OKAY
      Windows95:^C
      ______________________________________________________________________
      ======================================================================

        Attachments

          Activity

            People

            Assignee:
            jlockesunw Jonathan Locke (Inactive)
            Reporter:
            akuzminorcl Alexander Kuzmin (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: