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

JProgressBar Metal PLAF overwrites empty borders

    XMLWordPrintable

Details

    • Fix Understood
    • generic, x86
    • generic, windows_95, windows_nt, windows_2000

    Description

      Name: tb29552 Date: 10/28/98


      /*

      The JProgressBar Metal PLAF implementation as
      shipped in JDK 1.2rc1 overwites an empty border
      placed around it. The following code recreates
      the problem. When you run this example, you will
      see the border that the Metal PLAF is trying to
      draw around the progress bar. The paint routine
      in MetalProgressBarUI.java is the culprit.

      */
      import java.awt.*;
      import javax.swing.*;
      import javax.swing.border.*;

      public class pb_bug {

          public static void main(String[] args) {

              JFrame frame = new JFrame();
              frame.getContentPane().setLayout(new BorderLayout());

              JProgressBar pb = new JProgressBar();

              pb.setBorder(new EmptyBorder(10, 10, 10, 10));

              frame.getContentPane().add(pb, BorderLayout.CENTER);

              frame.show();

          }

      }

      (Review ID: 41450)
      ======================================================================

      Name: gm110360 Date: 04/19/2002


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

      FULL OPERATING SYSTEM VERSION :
      Microsoft Windows 2000 [Version 5.00.2195]



      A DESCRIPTION OF THE PROBLEM :
      If you set any type of border on a JProgressBar, extra
      lines are drawn on top and on the left of the bar. That is
      troublesome when you decide to use a line border. The bug
      can be easily seen when you for instance use a titled
      border.



      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. create a progress bar
      2. select a line border for it
      3.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      When a line border is selected, there should not be any
      extra line drawn inside the component along the border.


      This bug can be reproduced always.

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

      public class ProgressSample {
        public static void main (String args[]) {
          JFrame f = new JFrame("JProgressBar Sample");
          Container content = f.getContentPane();
          JProgressBar progressBar = new JProgressBar();
          progressBar.setValue(25);
          progressBar.setStringPainted(true);
          Border border = BorderFactory.createTitledBorder("Reading...");
          progressBar.setBorder(border);
          content.add(progressBar, BorderLayout.NORTH);
          f.setSize (300, 100);
          f.setVisible (true);
        }
      }

      ---------- END SOURCE ----------
      (Review ID: 138612)
      ======================================================================

      Attachments

        Activity

          People

            honkar Harshitha Onkar
            tbell Tim Bell
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Imported:
              Indexed: