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

double buffering in a scroll pane

XMLWordPrintable

    • generic
    • windows_nt

      Customer has implemented double buffering on a JPanel in a JViewport
      bordered by a column header and a row header in a JScrollPane. He wants
      to find a way to switch from one canvas to another, as when painting a
      picture at different scales, without flicker. By "canvas" we mean the
      result of calling paintComponent, setSize, setPreferredSize, and
      scrollRectToVisible (so that the proper rectangle of the new canvas is
      in view).

      This can be accomplished satisfactorily if the second canvas is no
      smaller than the first. But if the 2nd canvas is smaller than the 1st,
      we always get jiggling and sometimes even the headers blink.

      The attached test case demonstrates this problem (Customer reported this on
      1.3.0_02, I have tried the same with 1.3.1_07 with same results):

      1) Main program is ScrollXpt.java.

      2) When you execute the program you will see the whole canvas in the
         viewport (there are no headers in this test case).
         
      3) The slider beneath the viewport controls the scale of the canvas.
         Move the slider to, say, 70.
         
      4) Hit the C-key on the keyboard, and the canvas will be scrolled so that
         the little square is in the center of the view port. Move the slider 10
         divisions to the right, and you will zoom in on the canvas, holding the
         center fixed. This usually works as it should.
         
      5) But move the slider to the left, which should zoom out, holding the
         center fixed and all kinds of unpleasant effects occur.
         
         a- In this test case, we see a flicker and sometimes even the green
            border (problem looks much worse when the canvas is filled with
            brightly colored images).

         b- The center of the view also drifts downward. Again, it is not a
            problem when the scale is enlarged.

            svioletsunw Scott Violet (Inactive)
            gnagasunsunw Gopinath Nagasundara (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: