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

JRadioButton still does not obey border setting

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Duplicate
    • Affects Version/s: 1.4.0
    • Fix Version/s: None
    • Component/s: client-libs
    • Labels:

      Description



      Name: sv35042 Date: 10/18/2002


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

      FULL OPERATING SYSTEM VERSION :

      Microsoft Windows 2000 [Version 5.00.2195]



      A DESCRIPTION OF THE PROBLEM :
      Although bug report 4380543 says that the border margins
      are now obeyed, this is not correct.

      When using the default setHorizontalAlignment - (LEFT not
      RIGHT as in the doco by the way) the left border margin is
      ignored. When using RIGHT, the right margin is ignored.


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Run the example code
      2. Look at the button surround
      3. If you uncomment the setHorizontalAlignment line, you
      can see the problem shifts to the other end.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      The window should show a blank gap of 8 pixels to the left
      of the radio button icon within the border like there on
      the other three sides. Actually there is no gap. You can
      more clearly see the size of gap to the right if you take
      the <html></html> off the button text, as then it no longer
      expands the JRadioButton to fill the container on the right.

      If you follow step 3, the window should show a blank gap of
      8 pixels to the right of the button, but there is no gap.
      The other three sides have the expected gap.

      REPRODUCIBILITY :
      This bug can be reproduced always.

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

      public class JRadioButtonTest extends JFrame
      {
         JRadioButton testBtn = new JRadioButton("<html>Border should be
      (8,8,8,8).</html>");

          public JRadioButtonTest()
          {
            super("JRadioButton test");
            this.setSize(new Dimension(400, 200));
            Box box = new Box(BoxLayout.Y_AXIS);
            box.setBorder(BorderFactory.createEmptyBorder(20,20,20,20));
            this.setContentPane(box);

            testBtn.setBorderPainted(true);
         // testBtn.setHorizontalAlignment(SwingConstants.RIGHT);
            testBtn.setBorder(BorderFactory.createCompoundBorder(
               BorderFactory.createLoweredBevelBorder(),
               BorderFactory.createEmptyBorder(8,8,8,8) ) );
            box.add(testBtn);
            this.show();
         }
         
         public static void main(String[] args)
         {
            new JRadioButtonTest();
         }
      }
      ---------- END SOURCE ----------

      CUSTOMER WORKAROUND :
      The only workaround I can think of is to wrap a JPanel
      around the outside and set its border instead
      (Review ID: 158328)
      ======================================================================

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              shickeysunw Shannon Hickey (Inactive)
              Reporter:
              svioletsunw Scott Violet (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: