how to detect whether /java/awt/Graphics2D is available
Hello:
I have recently began using Graphics2D. It is my understanding that, say, the MS VM that comes standard with Windows does not include this library. Sun's Java 2 does.
If Graphics2D is not available, applets run and display whatever does not require Graphics2D, but, otherwise remain blank.
I would like to detect at run time the presence (or absence) of Graphics2D.
Question: How can I detect at run time availability of Graphics 2D.
Thank you,
Alex
[502 byte] By [
abogoma] at [2007-10-2 13:18:00]

Well, thank you for your reply. But somehow this does not work.
In most cases, all I want is antialiasing, so that lines look straight and circles round. This can be easily achieved with, say,
public void paint(Graphics g) {
( (Graphics2D) g).setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
...
}
This works if Graphics2D is available, but stops an applet from loading otherwise. The effect is a window with an icon in the upper left corner. Now, assume I want to do that conditionally, as
public void paint(Graphics g) {
try {
( (Graphics2D) g).setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
} catch (Exception ignored) {}
...
}
The applet loads but the Canvas with the above code does not paint. The window is grayish. With
public void paint(Graphics g) {
try {
BasicStroke stroke = new BasicStroke();
( (Graphics2D) g).setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
} catch (Exception ignored) {}
...
}
the effect is that the applet loads, the Canvas clears the window to my background, but then nothing else is drawn.
Nothing else came to mind so far.
Alex