Monday, August 18, 2008

Java Swing fonts in Java 6u10 : B.E.A.U.T.I.F.U.L.!


I've been known to make a few negative comments here and there about Sun's handling of Java recently, but I have to say they've really delivered on their Swing fidelity promises with the latest update.

The switch to using the native Windows font rasterizer for font rendering has made an enormous difference. It's just a pleasure to look at Swing applications now (and even though the Swing API is not perfect, I prefer it much more to SWT with its myriad of hard-coded SWT.* styles).

On the Linux front, the builds of OpenJDK 7 look really great on Ubuntu as well and have fixed most of the glaring GTK+ bugs.

Thank you Sun for a great job on this. It's good to see solid effort like this being put into maintaining Swing.

P.S. You asked for JDK 7 / GTK+ screenshots, so here they are:

Wednesday, August 13, 2008

Using JavaFX objects from within Java: a very bad joke from Sun

So I read this article about accessing JavaFX objects from within Java, which is quite easy, it seems:

http://java.sun.com/developer/technicalArticles/scripting/javafx/javafx_and_java/index.html

Hidden lower in the article is the first public example I see of the opposite scenario: accessing JavaFX classes from Java.

I was (naively) expecting this would be done the way Groovy does it...as real JVM classes that are interoperable across all JVM languages. But, as usual JavaFX shows its "thrown-together-in-a-hurry-as-a-response-to-Flex" roots:

public class Main {

public static void main (String[] args) {
ScriptEngineManager manager =
new ScriptEngineManager();

JavaFXScriptEngine fxEngine =
(JavaFXScriptEngine) manager.getEngineByName("javafx");

try {

String param = "JavaFX object created in Java";

String script = String.format (
"MyJavaFXClass {property: \"%s\"}", param);

Object o = fxEngine.eval(script);

fxEngine.invokeMethod(o, "printProperty");

} catch (Exception ex) {
ex.printStackTrace();
}
}
}
I mean, just beautiful, isn't it...who cares about type safety and static compiling, when we just expose a half-baked scripting interface.

The Silverlight/C# guys must be laughing their heads off looking at that sample.