Glyph Positioning in JFreeSVG & OrsonPDF

Object Refinery Ltd. makes two small but extremely useful Java libraries for producing vector graphics. JFreeSVG (free & commercial) supports Scalable Vector Graphics (SVG) and HTML5 Canvas output, and OrsonPDF (commercial with free demo) supports Adobe PDF output. Each provides a custom implementation of java.awt.Graphics2D, the 2D drawing surface for the Java AWT graphics library. … Continue reading “Glyph Positioning in JFreeSVG & OrsonPDF”

ListView Text Alignment

The ListView class of JavaFX 8 shows one item per line – one String in the simplest case. What if you want to visually separate individual string fragments (words, numbers)? You could use a TableView with multiple columns, but that may not be appropriate for your data. Or you could insert tab characters ("\t") into … Continue reading “ListView Text Alignment”

Simulating Platform.runAndWait

Every JavaFX application maintains one single JavaFX application thread running the application’s event queue, much like Swing’s event dispatch thread. System-generated events such as mouse clicks are automatically inserted into the event queue. JavaFX also provides the method Platform.runLater to programmatically enqueue an arbitrary Runnable function object. You might occasionally wish to call runLater from … Continue reading “Simulating Platform.runAndWait”

JavaFX Text Icons as Images & Files

There are plenty of high-quality icon fonts for scalable user interfaces, and drawing them directly as Text into JavaFX UIs is simple. But what if you need the icon as an Image or a disk file? That’s not hard to achieve, either, but there are some non-obvious steps and many Java APIs to navigate. So … Continue reading “JavaFX Text Icons as Images & Files”

JavaFX ListView Sizing

JavaFX supports automatic self-adjusting layout that resizes controls along with the containing window, but this may require some non-obvious changes to the controls’ default properties. The problem I recently ran into was automatically resizing a ListView within a VBox. This article describes the undesirable default behavior and its correction, based on JavaFX 2.2 in JDK … Continue reading “JavaFX ListView Sizing”

Jumping out of Java finally

The definition of the return statement in the current Java Language Specification (§14.17) features an innocuous-looking sentence: It can be seen, then, that a return statement always completes abruptly. Other statements that “always complete abruptly” include break (§14.15), continue (§14.16), and of course throw (§14.18). So what? Well, Java also has try-finally blocks (§14.20). As … Continue reading “Jumping out of Java finally”

Amazing NetBeans JAR Vanishing Act

Today I encountered a bizarre and obscure misbehavior of NetBeans 7.3.1 that you should be aware of when writing JavaFX applications. The situation: I wanted to add some text files to a JavaFX project that should be copied to the output folder at every build. The NetBeans way to do this is to add a … Continue reading “Amazing NetBeans JAR Vanishing Act”

Programming .NET 4.5 without VS2012

Back in the good old days, when the Windows start menu wasn’t designed for smartphones, the free Windows SDK 7.1 shipped with all .NET 4.0 compilers and even Visual C++. As noted previously, Microsoft decided to stop this generosity and removed all compilers from the new Windows SDK 8.0 for .NET 4.5. In the case … Continue reading “Programming .NET 4.5 without VS2012”

WinRT vs C# Overload Resolution

Browsing the Application Compatibility notes for the new .NET Framework 4.5, I noticed a very odd entry concerning Math.Ceiling and Math.Floor: Change: When you use .NET for Windows Store apps, C# may have difficulty with overload resolution when the Math.Ceiling or Math.Floor method is passed an integer. Impact: Source code may not compile successfully, or … Continue reading “WinRT vs C# Overload Resolution”