Tristate Checkbox for Swing

One modern GUI feature notably absent from Java Swing is the tristate checkbox, i.e. a checkbox that has a third or “null” state in addition to the checked and unchecked states. This is typically visualized as a square or dash in the checkbox, where the checked state would be a checkmark and the unchecked state … Continue reading “Tristate Checkbox for Swing”

Java Swing JComboBox Tips

This post is a sequel to Java Swing Tips which formerly contained a shorter version of these tips concerning JComboBox. I decided to extract them into their own post as they got rather long, and the section on custom rendering was not quite correct. As before I’m using Oracle OpenJDK 10 on Windows 10 for … Continue reading “Java Swing JComboBox Tips”

Swing Hyperlink Labels

JavaFX has a convenient Hyperlink control that’s functionally a button styled as an underlined label, just like an HTML hyperlink. Java Swing has clickable hyperlinks in its JEditorPane control but does not provide them as a separate lightweight control. Fortunately it’s quite easy to roll your own, and that’s what the code below does. JHyperlink … Continue reading “Swing Hyperlink Labels”

Vertical Swing Labels

One limitation of Java AWT/Swing is the inability to rotate controls such as labels, although you can freely rotate elements in a custom-drawn graphics context. I did try invoking a label’s paint method in a paintComponent override after rotating the graphics context but couldn’t get it to work, probably because of the label’s built-in assumptions … Continue reading “Vertical Swing Labels”

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”