JDK-6496144 : REGRESSION: JCheckBox doesn't show on JToolBar under Windows L&F
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 5.0,5.0u9,6
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2006-11-21
  • Updated: 2011-03-08
  • Resolved: 2011-03-08
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other JDK 6 JDK 7
5.0u11Fixed 6u1Fixed 7 b07Fixed
Related Reports
Duplicate :  
Relates :  
Relates :  
Relates :  
Description
JCheckBox does not appear in JToolBar in Windows L&F under XP. Try the following on XP in 5.0u9 (or later) or 6.0 or 7.0:

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

public class TBCBTest extends JFrame {
    
    public TBCBTest() {
        super("TBCBTest");
        
        JToolBar tb = new JToolBar();
        tb.add(new JCheckBox("One"));
        tb.add(new JCheckBox("Two"));
        tb.add(new JCheckBox("Three"));
        
        add(tb, BorderLayout.NORTH);
    }

    private static void createAndShowGUI(String[] args) {
        TBCBTest test = new TBCBTest();
        test.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        test.pack();
        test.setLocationRelativeTo(null);
        test.setVisible(true);
    }
    
    public static void main(final String[] args) {
        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                try {
                    UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
                } catch (Exception e) {
                }
                createAndShowGUI(args);
            }
        });
    }
}

The problem goes away if you use the -Dswing.noxp flag.

Comments
EVALUATION this regression was introduced by the fix for 6349010 [REGRESSION: XP L&F: on jdk 1.6, preferred size of JToggleButton in JToolbar on winxp is wrong.] -- Insets XPEmptyBorder.getBorderInsets(Component c, Insets insets) 415 insets.top -= 2; 416 insets.left -= 2; 417 insets.bottom -= 2; 418 insets.right -= 2; -- The resulting insets have nothing to do with the border. Moreover in case the same insets instance is used over and over again the values got smaller and smaller. We need to initialize insets first to the border values. insets.top = top; insets.left = left; insets.bottom = bottom; insets.right = right; I think we want border for JCheckBox and JRadioButton to be the same as before the fix for 6349010. Thus I suggest to make it a special case. There are two other problems related to this bug: 6497781 Should use Prop.CONTENTMARGINS instead of Prop.SIZINGMARGINS 6497784 thread unsafe use of static variables
28-11-2006

EVALUATION See the following forum for discussion and possible cause: http://forums.java.net/jive/thread.jspa?threadID=20362&tstart=0
21-11-2006