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

Nimbus L&F: AbstractRegionPainter.PaintContext doesn't accept null insets

    XMLWordPrintable

    Details

      Description

      The spec for javax.swing.plaf.nimbus.AbstractRegionPainter.PaintContext says:

               * @param insets The stretching insets. May be null. If null, then assumed to be 0, 0, 0, 0.

      In fact NPE is thrown. Please see the following code sample:
      ------------------------------------------------------------
      import javax.swing.*;
      import java.awt.*;

      public class Test {

          public static void main(String[] args) {

              class MyARP extends javax.swing.plaf.nimbus.AbstractRegionPainter {
                  protected PaintContext getPaintContext() {
                      return null;
                  }
                  protected void doPaint(Graphics2D g, JComponent c,
                                         int width, int height,
                                         Object[] extendedCacheKeys) {
                  }
                  void createPaintContext() {
                      new PaintContext(null, new Dimension(), true);
                  }
              }
              new MyARP().createPaintContext();
          }
      }
      -----------------------------------------------------------------
      The result will be:

      Exception in thread "main" java.lang.NullPointerException
      at javax.swing.plaf.nimbus.AbstractRegionPainter$PaintContext.<init>(AbstractRegionPainter.java:541)
      at javax.swing.plaf.nimbus.AbstractRegionPainter$PaintContext.<init>(AbstractRegionPainter.java:506)
      at Test$1MyARP.createPaintContext(Test.java:17)
      at Test.main(Test.java:20)

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              peterz Peter Zhelezniakov
              Reporter:
              dbessono Dmitry Bessonov
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: