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

MatteBorder JScrollpane interaction

    XMLWordPrintable

Details

    • b97
    • x86
    • solaris_8
    • Verified

    Description

      FULL PRODUCT VERSION :
      java version "1.6.0_17"
      Java(TM) SE Runtime Environment (build 1.6.0_17-b04)
      Java HotSpot(TM) Client VM (build 14.3-b01, mixed mode, sharing)


      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows [Version 6.0.6002]

      A DESCRIPTION OF THE PROBLEM :
      MatteBorder causes rendering problems when used on a component within a JScrollPane if an icon is specified in the border. If an icon is used the border, the border is painted on top of the JScrollPane headers and scroll bars.



      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Create button or any other component in a JScrollPane. Add a border with an icon specified instead of a color. Set the size of the component so that scrollbars are visible. Slide the scrollbars until the border is drawn incorrectly.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The border of a component within a JScrollPane should never be rendered on top of the JScrollBar scroll bars or headers.
      ACTUAL -
      The border is drawn on the scroll bars and headers.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------

      public class MatteBorderScrollPaneBug {
         public static void main(String[] args) {
            JButton center = new JButton("Center") {
               public Dimension getPreferredSize() {
                  return new Dimension(270, 270);
               }
            };
            Icon icon = new Icon() {
               public int getIconHeight() { return 11; }

               public int getIconWidth() { return 11; }

               public void paintIcon(Component c, Graphics g, int x, int y) {
                  g.setColor(Color.RED);
                  g.fillRect(x + 0, y + 0, getIconWidth(), getIconHeight());
               }
            };
            JFrame frame = new JFrame();
            JScrollPane scroller = new JScrollPane(center);
            frame.getContentPane().add(scroller, BorderLayout.CENTER);
            scroller.setRowHeaderView(new JButton("HEADER"));
            center.setBorder(BorderFactory.createMatteBorder(11, 11, 11, 11, icon));
            frame.setBounds(300, 300, 300, 300);
            frame.setVisible(true);
         }
      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Sublcass MatteBorder. Override paintBorder with copy of original method and comment out cg.setClip in each case. Ensure that supplied icon does not draw outside of the component.

      Attachments

        Activity

          People

            malenkov Sergey Malenkov (Inactive)
            ndcosta Nelson Dcosta (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: