-
Bug
-
Resolution: Duplicate
-
P2
-
None
-
7
-
generic
-
generic
For invalid X/Y values passed to methods javax.swing.plaf.nimbus.AbstractRegionPainter.decodeX/Y() java.lang.Assertion error is thrown which is unspecified. It is assumed that IllegalArgumentException would fit better for this case.
Please see the following code sample:
------------------------------------------------------------------------------------
import javax.swing.*;
import java.awt.*;
import java.awt.image.BufferedImage;
public class Test {
public static void main(String[] args) {
class MyARP extends javax.swing.plaf.nimbus.AbstractRegionPainter {
MyARP() {
// workaround for CR#6849331
paint(new BufferedImage(1, 1, BufferedImage.TYPE_INT_RGB).createGraphics(), new JButton(), 10, 10);
}
protected PaintContext getPaintContext() {
// workaround for CR#6849331
return new PaintContext(new Insets(1, 2, 3, 4), new Dimension(100, 100), true);
}
protected void doPaint(Graphics2D g, JComponent c,
int width, int height,
Object[] extendedCacheKeys) { }
void call() {
// decodeY(
decodeX(
-1.f
);
}
}
new MyARP().call();
}
}
------------------------------------------------------------------------------------
Execution will lead to:
Exception in thread "main" java.lang.AssertionError: Invalid x
at javax.swing.plaf.nimbus.AbstractRegionPainter.decodeX(AbstractRegionPainter.java:242)
at Test$1MyARP.call(Test.java:21)
at Test.main(Test.java:26)
Please see the following code sample:
------------------------------------------------------------------------------------
import javax.swing.*;
import java.awt.*;
import java.awt.image.BufferedImage;
public class Test {
public static void main(String[] args) {
class MyARP extends javax.swing.plaf.nimbus.AbstractRegionPainter {
MyARP() {
// workaround for CR#6849331
paint(new BufferedImage(1, 1, BufferedImage.TYPE_INT_RGB).createGraphics(), new JButton(), 10, 10);
}
protected PaintContext getPaintContext() {
// workaround for CR#6849331
return new PaintContext(new Insets(1, 2, 3, 4), new Dimension(100, 100), true);
}
protected void doPaint(Graphics2D g, JComponent c,
int width, int height,
Object[] extendedCacheKeys) { }
void call() {
// decodeY(
decodeX(
-1.f
);
}
}
new MyARP().call();
}
}
------------------------------------------------------------------------------------
Execution will lead to:
Exception in thread "main" java.lang.AssertionError: Invalid x
at javax.swing.plaf.nimbus.AbstractRegionPainter.decodeX(AbstractRegionPainter.java:242)
at Test$1MyARP.call(Test.java:21)
at Test.main(Test.java:26)
- duplicates
-
JDK-6849331 Nimbus L&F: AbstractRegionPainter's paint context is not initialized
- Resolved