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

setBorderPainted(true) does not work in JCheckBox inside a JToolBar

XMLWordPrintable

    • beta2
    • x86
    • windows_nt



      Name: boT120536 Date: 06/03/2001


      java version "1.4.0-beta"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta-b65)
      Java HotSpot(TM) Client VM (build 1.4.0-beta-b65, mixed mode)

      Regression in JCheckBox.setBorderPainted(true) when the JCheckBox is inside a
      JToolBar.
      The border is drawn like a JButton border.

      The code below shows the different rendering of a JCheckBox:
      . located in a JToolBar
      . located in a JPanel

      Note: the same code compiled and run under:
      . jdk 1.3.0,
      . jdk 1.3.1-beta
      . jdk 1.3.1
      ... works great

      --------

      import javax.swing.*;

      import java.awt.*;
      import java.awt.event.*;

      public class FTestCheckBox extends JFrame
      {
          final static private int _f_s_intW = 600;
          final static private int _f_s_intH = 400;
          
          static public void main(String[] args)
          {
              FTestCheckBox tcb = new FTestCheckBox();

              tcb.pack();
              tcb.setVisible(true);
          }
          
          
          public FTestCheckBox()
          {
              super("test border painted in a checkbox");
              
              setSize(_f_s_intW, _f_s_intH);
              
              addWindowListener(new WindowAdapter()
              {
                  public void windowClosing(WindowEvent e) { System.exit(0); }
              });
              
              
              JToolBar tbr = new JToolBar();
              
              JPanel pnl = new JPanel();
              
              Container cnt = getContentPane();
              
              cnt.setLayout(new BorderLayout());
              
              cnt.add(tbr, BorderLayout.NORTH);
              cnt.add(pnl, BorderLayout.CENTER);
              
              
              tbr.setBackground(Color.green);
              pnl.setBackground(Color.yellow);
              
              
              
              // --
              
              tbr.add(_getButton());
              tbr.addSeparator();
              tbr.add(_getCheckBox());
              
              pnl.add(_getButton());
              pnl.add(_getCheckBox());
          }
          
          
          private JCheckBox _getCheckBox()
          {
              JCheckBox cbx = new JCheckBox("checkbox");
              cbx.setBorderPainted(true);
              return cbx;
          }
          
          private JButton _getButton()
          {
              JButton btn = new JButton("button");
              btn.setBorderPainted(true);
              return btn;
          }
      }
      (Review ID: 125502)
      ======================================================================

            mdavidsosunw Mark Davidson (Inactive)
            bonealsunw Bret O'neal (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: