Swing High DPI Properties

When Java AWT/Swing got JavaFX-style automatic high DPI scaling in Java SE 9, there were also several new system properties to control that scaling. Unfortunately, as with the various glass.win.* properties of JavaFX (see e.g. here) they are not officially documented. You need to check the developer mailing list and the JDK test sources to … Continue reading “Swing High DPI Properties”

Minimum Size Scaling for Swing Windows

Since Java SE 9, Java AWT/Swing has supported automatic high DPI scaling on Windows and Linux, just like JavaFX. Ironically, this came with a bug that JavaFX used to have until Java 9: Window.setMinimumSize fails to scale the specified width and height on high DPI systems. (Unlike JavaFX, AWT/Swing windows ignore setMaximumSize anyway. Non-window components … Continue reading “Minimum Size Scaling for Swing Windows”

3DViewer: Better 3D for JavaFX

JavaFX has long had basic 3D capabilities, although you might not guess it as some outdated package descriptions still only speak of “two-dimensional geometry.” Oracle offers an online tutorial for JavaFX 3D, and JavaFX by Example devotes a chapter to it. Here’s a brief overview: Package javafx.geometry defines a 3D bounding box and a fairly … Continue reading “3DViewer: Better 3D for JavaFX”

Programming .NET without Visual Studio

Back in 2013 I wrote about Programming .NET 4.5 without VS2012. The reason was that Microsoft had yanked its free compilers from the free Windows SDK, yet Visual Studio at the time did not offer a reasonable free option. The first point still holds, the second does not. You can now simply download the free … Continue reading “Programming .NET without Visual Studio”

Beware of Java’s inconsistent MIN_VALUE

An astute user of my Tektosyne library noticed that I had made a simple but disastrous copy-paste mistake regarding the floating-point versions of some basic algorithms, such as finding the maximum of an array of numbers. The integral versions initialize the return value to e.g. Integer.MIN_VALUE and then check for any greater values. I copied … Continue reading “Beware of Java’s inconsistent MIN_VALUE”

Catching Java Assertion Errors

The Java assert statement can be used for conditionally checking program invariants. Assertions are enabled or disabled with the desired level of granularity by Java Virtual Machine flags, as described in the linked guide. So far, so similar to assertion facilities in other languages. However, whereas .NET Debug/Trace.Assert shows and logs a message by default, … Continue reading “Catching Java Assertion Errors”

JavaFX Chart Coloring

Working on a Java(FX) port of my hoplite simulator Myriarch, I ran into an unexpected problem with the history chart. This part of the “Simulation Report” dialog shows how each faction’s unit count changes over the course of the simulation. You can see a screenshot from the current build below. The control is a standard … Continue reading “JavaFX Chart Coloring”

Compiling Java Code

This post is a quick introduction aimed at programmers experienced with C# or other languages who are new to Java. It is intended as a companion piece to my article Java for C# Programmers which focuses on language differences. See the “Further Reading” section at the top of that article for the official Oracle tutorials … Continue reading “Compiling Java Code”

JavaFX Snapshot Scaling

If you try taking image snapshots of a JavaFX Node on a high-DPI system, you’ll find that the result is strangely blurry. This is an unfortunate side effect of the JavaFX DPI scaling introduced in Java SE 8u60. At resolutions greater than 120 DPI, JavaFX automatically treats all coordinates as abstract “layout pixels” with a … Continue reading “JavaFX Snapshot Scaling”