-
Bug
-
Resolution: Duplicate
-
P2
-
None
-
7
-
generic
-
generic
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)
* @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)
- duplicates
-
JDK-6849331 Nimbus L&F: AbstractRegionPainter's paint context is not initialized
- Resolved