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

JCheckBox can't show check when the background color is black

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 6
    • 1.3.0, 1.4.1
    • client-libs
    • beta
    • x86
    • windows_nt, windows_xp

      Name: yyT116575 Date: 04/23/2001


      D:\liu\util>java -version
      java version "1.3.1-rc1"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1-rc1-b21)
      Java HotSpot(TM) Client VM (build 1.3.1-rc1-b21, mixed mode)

      The color of the checkmark in JCheckBox is always black, even you set the
      foreground color. So the background color is black, one can't tell if the
      checkBox is checked or not. The color of the JCheckBox square change to
      white when the background is black, so why not change the color of the
      checkmark to white as well! In fact, the color of the checkmark should be
      the foreground color, as the color of the text of JCheckBox does.

      import java.awt.*;
      import javax.swing.*;

      public class CheckBoxTest {
        public static void main(String[] args) {
          JFrame f = new JFrame();
          f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          f.getContentPane().setLayout(new FlowLayout());

          JCheckBox c1 = new JCheckBox("CheckBox1");
          c1.setBackground(Color.red);
          c1.setForeground(Color.white);

          JCheckBox c2 = new JCheckBox("CheckBox2");
          c2.setBackground(Color.black);
          c2.setForeground(Color.white);

          JCheckBox c3 = new JCheckBox("CheckBox3");
          c3.setBackground(Color.white);
          c3.setForeground(Color.red);

          JRadioButton b1 = new JRadioButton("RadioButton1");
          b1.setBackground(Color.red);
          b1.setForeground(Color.white);

          JRadioButton b2 = new JRadioButton("RadioButton2");
          b2.setBackground(Color.black);
          b2.setForeground(Color.white);

          JRadioButton b3 = new JRadioButton("RadioButton3");
          b3.setBackground(Color.white);
          b3.setForeground(Color.red);

          f.getContentPane().add(c1);
          f.getContentPane().add(c2);
          f.getContentPane().add(c3);
          f.getContentPane().add(b1);
          f.getContentPane().add(b2);
          f.getContentPane().add(b3);
          f.setSize(350,100);
          f.show();
        }

      }
      (Review ID: 121244)
      ======================================================================

      Name: jk109818 Date: 08/26/2002


      FULL PRODUCT VERSION :
      java version "1.4.1-rc"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1-rc-b19)
      Java HotSpot(TM) Client VM (build 1.4.1-rc-b19, mixed mode)

      FULL OPERATING SYSTEM VERSION :
      Microsoft Windows XP [Version 5.1.2600]

      A DESCRIPTION OF THE PROBLEM :
      JCheckBox.setForeground() doesn't change the color of the
      check mark. The check mark is always black. It would be
      nice if it were set to the foreground color of the rest of
      the JCheckBox.

      Because of this, the check marks are difficult or even
      impossible to see when one is using dark backgrounds in
      JPanels and such.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.awt.*;
      import javax.swing.*;

      class Simple
      {
           public static void main(String args[])
           {
                JCheckBox checkBox = new JCheckBox("Invisible check mark");
                checkBox.setBackground(SystemColor.darkGray);
                checkBox.setForeground(SystemColor.white);

                JPanel jpanel = new JPanel();
                jpanel.add(checkBox);
                jpanel.setBackground(SystemColor.darkGray);

                JFrame jframe = new JFrame();
                jframe.setDefaultCloseOperation(jframe.EXIT_ON_CLOSE);
                jframe.getContentPane().add(jpanel);
                jframe.setBounds(300,300,300,100);
                jframe.setVisible(true);
           }
      }

      ---------- END SOURCE ----------
      (Review ID: 163594)
      ======================================================================
      ###@###.### 10/13/04 17:52 GMT

            shickeysunw Shannon Hickey (Inactive)
            yyoungsunw Yung-ching Young (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: