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

Drawing bugs when using emptyBorder with button classes



      Name: skT88420 Date: 06/07/99

      The use of an empty border has several bugs when used
      with AbstractButton subclass buttons(ie JButton,
      JCheckBox, JRadioButton, etc). The problems range
      from not having the padding of the empty border applied
      correctly to having the focus rectangle drawn on top
      of the area covered by the empty border. The following
      table lists the specific problems while the code at
      the end can be used to demonstrate all of the problems.
      The only scenario showing totally correct behavior was
      the JButton class displayed with the Motif look and feel.
      When running the test program the LF can be set by supplying
      either "metal", "win" or "motif" as the command line argument.

                | | Empty | Btn bgd | Focus rect
      Button | Look/ | padding | painted on | is drawn
      Class | Feel | correct? | empty border? | correctly?
      JButton | Metal | Yes | Yes (WRONG) | Yes
                | Windows | Yes | Yes (WRONG) | No (WRONG)
                | Motif | Yes | No | Yes
      JCheckBox | Metal | No (WRONG) | Yes (WRONG) | Yes
                | Windows | No (WRONG) | Yes (WRONG) | Yes
                | Motif | No (WRONG) | Yes (WRONG) | No (WRONG)

      //~~~~~~~~~~~~~~~~~~~~~~~~~~ CODE ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      import java.awt.*;
      import java.awt.event.*;
      import javax.swing.*;

      public class bug extends JFrame {

          public static void main(String args[]) {
              String METAL = "javax.swing.plaf.metal.MetalLookAndFeel";
              String MOTIF = "com.sun.java.swing.plaf.motif.MotifLookAndFeel";
              String WIN = "com.sun.java.swing.plaf.windows.WindowsLookAndFeel";
              String lnf = METAL;
              if (args.length == 1) {
                  if (args[0].equals("motif"))
                      lnf = MOTIF;
                  else if (args[0].startsWith("win"))
                      lnf = WIN;
              try {
              } catch (Exception e) {}

              JFrame f = new JFrame();
              f.addWindowListener(new WindowAdapter() {
                  public void windowClosing(WindowEvent e) {System.exit(0);}
              JButton btn1 = new JButton("JButton (pad top)");
              JButton btn2 = new JButton("JButton (pad left)");
              JButton btn3 = new JButton("JButton (pad bottom)");
              JButton btn4 = new JButton("JButton (pad right)");
              JCheckBox ckbox1 = new JCheckBox("JCheckBox (pad top)");
              JCheckBox ckbox2 = new JCheckBox("JCheckBox (pad left)");
              JCheckBox ckbox3 = new JCheckBox("JCheckBox (pad bottom)");
              JCheckBox ckbox4 = new JCheckBox("JCheckBox (pad right)");



              Container cp = f.getContentPane();
              cp.setLayout(new BoxLayout(cp, BoxLayout.Y_AXIS));


      (Review ID: 84001)




            • Assignee:
              skonchad Sandeep Konchady
            • Votes:
              0 Vote for this issue
              1 Start watching this issue


              • Created: