-
Bug
-
Resolution: Unresolved
-
P3
-
None
-
6
-
Fix Understood
-
x86
-
linux
FULL PRODUCT VERSION :
java version "1.6.0_03"
Java(TM) SE Runtime Environment (build 1.6.0_03-b05)
Java HotSpot(TM) Server VM (build 1.6.0_03-b05, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Linux 2.6.22-14-generic #1 SMP Sun Oct 14 23:05:12 GMT 2007 i686 GNU/Linux
A DESCRIPTION OF THE PROBLEM :
If a View (specifically, an HTMLView) is painted to a Graphics object with no 'clip' specified, a NullPointerException is thrown.
The stacktrace (below) show it is a problem in BoxView.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Create an HTMLView and then paint it (e.g. to a BufferedImage) with no clip bounds specified.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
Exception in thread "main" java.lang.NullPointerException
at javax.swing.text.BoxView.paint(BoxView.java:409)
at javax.swing.text.html.BlockView.paint(BlockView.java:265)
at javax.swing.plaf.basic.BasicHTML$Renderer.paint(BasicHTML.java:464)
at ViewTest.<init>(ViewTest.java:24)
at ViewTest.main(ViewTest.java:28)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.Rectangle;
import java.awt.Shape;
import java.awt.image.BufferedImage;
import javax.swing.JComponent;
import javax.swing.plaf.basic.BasicHTML;
import javax.swing.text.View;
public class ViewTest extends JComponent {
public ViewTest() {
BufferedImage image = new BufferedImage(100, 100, BufferedImage.TYPE_INT_RGB);
Graphics2D g = image.createGraphics();
Shape sh = new Rectangle(0, 0, 100, 100);
View view = BasicHTML.createHTMLView(this, "<p>Text.</p>");
g.setPaint(Color.BLACK);
g.fill(sh);
g.setPaint(Color.WHITE);
// Works fine when this line is uncommented.
//g.setClip(sh);
view.paint(g, sh);
}
public static void main(String[] args) {
ViewTest test = new ViewTest();
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Set the clip to be large enough for the view - e.g. the size of the component to be painted.
java version "1.6.0_03"
Java(TM) SE Runtime Environment (build 1.6.0_03-b05)
Java HotSpot(TM) Server VM (build 1.6.0_03-b05, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Linux 2.6.22-14-generic #1 SMP Sun Oct 14 23:05:12 GMT 2007 i686 GNU/Linux
A DESCRIPTION OF THE PROBLEM :
If a View (specifically, an HTMLView) is painted to a Graphics object with no 'clip' specified, a NullPointerException is thrown.
The stacktrace (below) show it is a problem in BoxView.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Create an HTMLView and then paint it (e.g. to a BufferedImage) with no clip bounds specified.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
Exception in thread "main" java.lang.NullPointerException
at javax.swing.text.BoxView.paint(BoxView.java:409)
at javax.swing.text.html.BlockView.paint(BlockView.java:265)
at javax.swing.plaf.basic.BasicHTML$Renderer.paint(BasicHTML.java:464)
at ViewTest.<init>(ViewTest.java:24)
at ViewTest.main(ViewTest.java:28)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.Rectangle;
import java.awt.Shape;
import java.awt.image.BufferedImage;
import javax.swing.JComponent;
import javax.swing.plaf.basic.BasicHTML;
import javax.swing.text.View;
public class ViewTest extends JComponent {
public ViewTest() {
BufferedImage image = new BufferedImage(100, 100, BufferedImage.TYPE_INT_RGB);
Graphics2D g = image.createGraphics();
Shape sh = new Rectangle(0, 0, 100, 100);
View view = BasicHTML.createHTMLView(this, "<p>Text.</p>");
g.setPaint(Color.BLACK);
g.fill(sh);
g.setPaint(Color.WHITE);
// Works fine when this line is uncommented.
//g.setClip(sh);
view.paint(g, sh);
}
public static void main(String[] args) {
ViewTest test = new ViewTest();
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Set the clip to be large enough for the view - e.g. the size of the component to be painted.