[EMAIL PROTECTED] wrote:
I have found a solution or work around for my own question.
The exception is thrown in Rectangle.intersect(Rectangle r) that was called
with a null parameter as a result of BoxView.paint getting a null pointer back
from g.getClipBounds().
As a workaround I have changed my paintComponents method as follows:
///
public void paintComponent(Graphics g) {
super.paintComponent(g);
if (isEnabled()) {
return;
}
BufferedImage buf = new BufferedImage(getWidth(), getHeight(),
BufferedImage.TYPE_INT_RGB);
Graphics2D g2 = (Graphics2D) buf.getGraphics();
g2.setClip(g.getClip()); // Simply copy the clip
super.paintComponent(g2);
float[] my_kernel = { 0.10f, 0.10f, 0.10f, 0.10f, 0.20f, 0.10f,
0.10f,0.10f, 0.10f };
ConvolveOp op = new ConvolveOp(new Kernel(3, 3, my_kernel));
Image img = op.filter(buf, null);
g.drawImage(img, 0, 0, null);
g2.dispose();
}
One question remains, is this a bug in the Java2D or my programming error?
I'd say it may be a bug in javax.text code - they don't
expect a null clip.
Also, a suggestion on your code. I'm not sure if it's just for
illustration, but I would suggest not to create a new
image on each repaint as you do currently.
You should only create a new image if the size of the
component changed (or if you have some other attributes like
text that can change).
Thanks,
Dmitri
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA2D-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".