A
A. Farber
Hello,
I have a small multiplayer card game applet
( http://preferans.de ) which I try to keep runnable both by
the Sun's JVM and by the old MSIE VM (msjavax86.exe).
There is however one little thing which I'd like to add to it
w/o breaking it for MSIE users: the antialiased fonts.
So I've created this small test case - Anti.java:
import java.awt.*;
import java.applet.*;
public class Anti extends Applet {
public void init() {
setFont(new Font("Serif", Font.ITALIC, 36));
}
void enableAntiAlias(Graphics g) {
((Graphics2D) g).setRenderingHint(
RenderingHints.KEY_TEXT_ANTIALIASING,
RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
((Graphics2D) g).setRenderingHint(
RenderingHints.KEY_RENDERING,
RenderingHints.VALUE_RENDER_QUALITY);
}
public void paint(Graphics g) {
/*
if
(System.getProperty("java.vendor").startsWith("Microsoft"))
System.err.println("MSIE detected");
else
enableAntiAlias(g);
*/
g.drawString("Hello World!", 10, getSize().height / 2);
}
}
And here is the html-file for your convenience:
<HTML>
<BODY>
<APPLET CODE="Anti" HEIGHT="100" WIDTH="300">
</APPLET>
</BODY>
</HTML>
If I comment the 4 lines in the paint() as listed above,
then MSIE loads and displays the applet w/o problems.
However once I remove the comments, I get this error:
Microsoft (R) VM for Java, 5.0 Release 5.0.0.3810
==============================================
java.lang.ClassNotFoundException: java.awt.Graphics2D
at com/ms/vm/loader/URLClassLoader.loadClass
at java/lang/ClassLoader.loadClassInternal
at Anti.paint
at com/ms/awt/WComponentPeer.doClearAndPaint
at com/ms/awt/WComponentPeer.paintNode
at com/ms/ui/windowmanager/PaintRequest.run
at com/ms/ui/windowmanager/RunnableMessage.run
at com/ms/awt/WSystemQueue.getMessage
at com/ms/awt/WEventQueue.getNextEvent
at java/awt/EventDispatchThread.run
I wonder if anyone have found a nice workaround for this
probably very frequent problem.
Please note, that I don't want to use JS or "Anti.cab"
or teach my users how to install the Sun's VM.
I just want them to play my little game with any browser.
Regards
Alex
I have a small multiplayer card game applet
( http://preferans.de ) which I try to keep runnable both by
the Sun's JVM and by the old MSIE VM (msjavax86.exe).
There is however one little thing which I'd like to add to it
w/o breaking it for MSIE users: the antialiased fonts.
So I've created this small test case - Anti.java:
import java.awt.*;
import java.applet.*;
public class Anti extends Applet {
public void init() {
setFont(new Font("Serif", Font.ITALIC, 36));
}
void enableAntiAlias(Graphics g) {
((Graphics2D) g).setRenderingHint(
RenderingHints.KEY_TEXT_ANTIALIASING,
RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
((Graphics2D) g).setRenderingHint(
RenderingHints.KEY_RENDERING,
RenderingHints.VALUE_RENDER_QUALITY);
}
public void paint(Graphics g) {
/*
if
(System.getProperty("java.vendor").startsWith("Microsoft"))
System.err.println("MSIE detected");
else
enableAntiAlias(g);
*/
g.drawString("Hello World!", 10, getSize().height / 2);
}
}
And here is the html-file for your convenience:
<HTML>
<BODY>
<APPLET CODE="Anti" HEIGHT="100" WIDTH="300">
</APPLET>
</BODY>
</HTML>
If I comment the 4 lines in the paint() as listed above,
then MSIE loads and displays the applet w/o problems.
However once I remove the comments, I get this error:
Microsoft (R) VM for Java, 5.0 Release 5.0.0.3810
==============================================
java.lang.ClassNotFoundException: java.awt.Graphics2D
at com/ms/vm/loader/URLClassLoader.loadClass
at java/lang/ClassLoader.loadClassInternal
at Anti.paint
at com/ms/awt/WComponentPeer.doClearAndPaint
at com/ms/awt/WComponentPeer.paintNode
at com/ms/ui/windowmanager/PaintRequest.run
at com/ms/ui/windowmanager/RunnableMessage.run
at com/ms/awt/WSystemQueue.getMessage
at com/ms/awt/WEventQueue.getNextEvent
at java/awt/EventDispatchThread.run
I wonder if anyone have found a nice workaround for this
probably very frequent problem.
Please note, that I don't want to use JS or "Anti.cab"
or teach my users how to install the Sun's VM.
I just want them to play my little game with any browser.
Regards
Alex