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

Flush() in Volatile image doesn't make contentsLost.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 6
    • 5.0u1
    • client-libs
    • 2d
    • 5.0
    • 5.0
    • b02
    • x86
    • linux
    • Verified

      There is next phrase in spec for
      method flush of class java.awt.image.VolatileImage.
       This method will cause the contents of the image to be lost, so calls to contentsLost() will return true and the image must be validated before it can be used again.
      But it is wrong. See next example.
      -------------------------------------------------------------------------------------------------------
      import java.awt.*;
      import java.awt.image.*;
      class Flush {
          final static int width = 40;
          final static int height = 20;
          static GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
          static GraphicsDevice gd = ge.getDefaultScreenDevice();
          static GraphicsConfiguration gc = gd.getDefaultConfiguration();

          public static VolatileImage createVolatileImage(){
              VolatileImage vi = gc.createCompatibleVolatileImage(width, height);
              return vi;
          }

          public static void main(String[] a) {
              VolatileImage vi = createVolatileImage();
              vi.flush();
              if (!vi.contentsLost()) {
                  System.out.println("contentsLost returned false after flush.");
              }
          }
      }
      ###@###.### 10/11/04 11:11 GMT

            tdv Dmitri Trembovetski (Inactive)
            lmesnik Leonid Mesnik
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: