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

JCheckBox and a few other controls do not paint correctly on a JToolBar

XMLWordPrintable

      FULL PRODUCT VERSION :
      Microsoft Windows [Version 6.3.9600]
      (c) 2013 Microsoft Corporation. All rights reserved.

      C:\Users\Owner>java -version
      java version "1.8.0_71"
      Java(TM) SE Runtime Environment (build 1.8.0_71-b15)
      Java HotSpot(TM) Client VM (build 25.71-b15, mixed mode)

      C:\Users\Owner>

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows [Version 6.3.9600]
      (c) 2013 Microsoft Corporation. All rights reserved.

      C:\Users\Owner>ver

      Microsoft Windows [Version 6.3.9600]

      C:\Users\Owner>

      A DESCRIPTION OF THE PROBLEM :
      When a JCheckBox is placed on a JToolBar under the Swing look and feel and a few of the derived look and feels, it is painted with no background. This looks odd on the toolbar as it tries to make it behave like a button which it is not.
      http://i.imgur.com/dHZ6Yfx.png

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Create a new application and set the default Swing look and feel
      2. Create a JToolbar
      3. Add a JCheckBox to the JToolBar
      4. Run the program and notice the lack of gradient.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      I would expected the toolbar to continue painting its gradient background behind the JCheckBox.
      ACTUAL -
      The JToolBar does not paint the gradient behind the JCheckBox.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      CUSTOMER SUBMITTED WORKAROUND :
      It can be corrected by making the checkbox non-opaque, but this should be the default behavior in the SE.
      checkbox.setOpaque(false);

      An alternative is to set the border to be painted which also makes it less out of place, but the border is still a different color than that for toolbar buttons in the Swing look and feel unless manually overridden.
      checkbox.setBorderPainted(true);

      SUPPORT :
      YES

            Unassigned Unassigned
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: