Java Choice setBackground method is not implemented consistently in Macintosh OS X Public Beta (Apple Problem ID#: 2661390)

 

    This applet behaves correctly in various browsers on Windows - showing two Choice components with ugly green text on red background for the items in the Choices.  On Macintosh OS 9.0.4 (with MRJ 2.2.4 in Internet Explorer 5.0) the green text and red background do not appear (it is black on white), but this is an old issue; Apple contends that implementing setBackground and setForeground would mess up the Macintosh look and feel.  This report focuses on the OS X behavior, ignoring the OS 9 issue.  In Macintosh OS X Public Beta (in MRJAppletLauncher), the behavior appears initially to be like that in OS 9: the green text and red background do not appear (it is black on white).  However, after an item is selected in one Choice a rim of the background color (red) appears around the border of the Choice component selected.  This red rim is most prominent on the left margin of the Choice.  Clicking the other Choice component gives it a red rim but does not remove the red rim of the first Choice component.  Clicking outside the applet results in a red rim around both Choice components.  Clicking within the applet but not on either Choice component does not bring on the red rim.
    This is fixed in OS 10.1 with MRJ 3.1.
    In summary, we see a rim of implementation of setBackground, inconsistently implemented.  This should be made consistent.  Ideally this consistency would be achieved by implementing setBackground and setForeground as done on other Java platforms, but if this is not done than at least a more consistent approach to implementation of setBackground and setForeground should be used.

    If you have any insights, workarounds or comments about this test page please contact Mickey Segal.  A listing of  many Macintosh Java bugs with demonstration applets is at this link, including information on how to add any necessary Java plugins.

    The code for this applet is available from this link and displayed below:

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

public class TwoChoices extends Applet {

public void init()
{
    int numberOfChoices = 2;
    Choice[] choice = new Choice[numberOfChoices];
    Font f = new Font("Serif",Font.BOLD,20);
    for (int j=0; j<numberOfChoices; j++)
    {
        choice[j] = new Choice();
        for (int i=0; i<3; i++) choice[j].addItem(String.valueOf(i) + " ");
        choice[j].setBackground(Color.red);
        choice[j].setForeground(Color.green);
        choice[j].setFont(f);
        add(choice[j]);
    }
}
} // END OF Class TwoChoices