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

Image drawn with wrong backgrd color if backgrd set from SystemColor (1.1/win32)

XMLWordPrintable

    • x86
    • windows_95, windows_nt

      orig synopsis:
         "The color with which a image from createImage() is filled is not correct"


      Name: dgC58589 Date: 12/08/97


      The color with which a image's background is
      filled with when created using createImage()
      is not consistent.

      1. If the Panel's background is set with
      Color.xxxx, the image's background is xxxx.

      2. If the Panel's background is set with
      SystemColor.xxxx, the image's background is black.

      Running the program below without a param would
      show case 1 and with param as case 2.
      -------------------------------------------

      import java.awt.*;

      public class ColorBug extends Panel {
          public void paint(Graphics g) {
              Image temp = createImage(100, 100);
              if (temp != null) {
                  g.drawImage(temp, 0, 0, null);
                  //IF setBackground(SystemColor.window) is used,
                  // this draws a black rectangle
                  //BUT IF setBackground(Color.red) is used,
                  // this draws a red rectangle
              }
          }

          public static void main(String[] args) {
              Frame f = new Frame();
              ColorBug bug = new ColorBug();
              if (args.length > 0)
                  bug.setBackground(SystemColor.window);
              else
                  bug.setBackground(Color.red);
              f.add(bug);
              f.setSize(200, 200);
              f.show();
          }
      }

      ------------------------------------

      In my opinion, the way it works with Color.xxx,
      is correct. Then I would not need to fill the
      image created with the background color of the
      Panel.


      (Review ID: 21498)
      ======================================================================

            prssunw Prs Prs (Inactive)
            dgrahamcsunw David Graham-cumming (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: