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

MatteBorder doesn't take into account current clipping area

    XMLWordPrintable

Details

    Description



      Name: skT45625 Date: 06/14/2000


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

      This bug shows up when using MatteBorder with a tiled icon.
      The problem is because the paintBorder() method uses setClip() which does not
      take into account the current clipping area. Replacing setClip() with
      clipRect() will fix the problem.


      ///---
      /// The following code demonstrate the problem
      ///
      import java.awt.*;
      import javax.swing.*;
      import javax.swing.border.LineBorder;
      import javax.swing.border.MatteBorder;

      /*
       * If you resize the frame to a size smaller than the inner panel,
       * the inner panel's border will be drawn on top of the
       * outter panel's border.
       *
       * To see the problem in a more meaningfull application
       * see http://ucsub.colorado.edu/~sudomo/private/matteborder.html
       */
      public class Test {
          public static void main(String[] args) {
              JFrame f = new JFrame();
              f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

              // outter panel
              JPanel outter = new JPanel();
              outter.setBorder(new LineBorder(Color.red, 10));

              // inner panel
              JPanel inner = new JPanel();
              inner.setBorder(new MatteBorder(new ImageIcon("my_icon.gif")));
              inner.setPreferredSize(new Dimension(100, 100));

              outter.add(inner);
              f.setContentPane(outter);

              f.setSize(200, 100);
              f.setVisible(true);
          }
      }
      ///
      ///---
      (Review ID: 106165)
      ======================================================================

      Attachments

        Issue Links

          Activity

            People

              apikalev Andrey Pikalev
              skondamasunw Suresh Kondamareddy (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: