FIX: Setting Colors for List/Choice Control Fails

ID: Q188448

The information in this article applies to:

SYMPTOMS

When trying to change the color of the List or Choice control using SetBackground and SetForeground, you will notice that it does not set the colors properly.

STATUS

Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. This bug has been corrected in the Java Virtual Machine distributed with Internet Explorer 4.01 Service Pack 1 and later.

MORE INFORMATION

Steps to Reproduce Behavior

1. Save the following to a file named TestColor.java:

      import java.applet.Applet;
      import java.awt.*;

      public class TestColor extends Applet
      {
         public void init()
         {
            List l = new List();
            add(l);
            l.addItem( "1" );
            l.addItem( "2" );
            l.addItem( "3" );
            l.setBackground(Color.blue);
            l.setForeground(Color.yellow);

            Choice c = new Choice();
            add( c );
            c.addItem( "1" );
            c.addItem( "2" );
            c.addItem( "3" );
            c.setBackground(Color.blue);

            Scrollbar sb = new Scrollbar(Scrollbar.VERTICAL);
            add( sb);
            sb.setBackground(Color.blue);
         }
      }

2. Compile the file.

3. Run the applet in Internet Explorer 4.0x.

4. The Choice control paints the specified background color, blue, in the

   button that drops down the choices. The expected system color for
   buttons is gray in the default Window desktop theme. The Foreground
   color of the List control does not change to yellow.

   In addition, the Scrollbar's arrows and thumb change to the new
   background color, blue, instead of the expected system color for
   buttons (gray in the default Window desktop theme).

This bug will appear in builds of the Virtual Machine for Java prior to the distribution vehicles listed above.

Additional query words: color choice list background kbDSupport

Keywords          : JVM 
Version           : WINDOWS:
Platform          : WINDOWS
Issue type        : kbbug
Solution Type     : kbfix

Last Reviewed: June 27, 1998