Featured Post

Applying Email Validation to a JavaFX TextField Using Binding

This example uses the same controller as in a previous post but adds a use case to support email validation.  A Commons Validator object is ...

Tuesday, August 1, 2017

Wire Level REST Request Logging in TornadoFX

TornadoFX's Rest class integrates RESTful web service calls into your JavaFX app.  There is a switch you can set that will allow you to use the Apache HTTPClient in place of the native Kotlin implementaton typically used in TornadoFX.  One feature that this switch brings is wire-level logging.


Friday, July 14, 2017

Op Amp Frequency Response for Bass Guitar Effects

This is a comparison of the frequency response of the OPA2132 and LM358N operational amplifiers.  These are two ICs that vary widly in price.  The OPA2132 is $6 while the LM358N is $0.40.  Both chips each contain a pair of op amps.  A few screenshots visually showing some differences is followed up by a pair of bass guitar effect circuits that highlight some audio application differences.


Tuesday, May 30, 2017

JavaFX Image Error Handling

ImageView is a JavaFX node that contains an Image.  When working with a classpath resource, an error is thrown immediately if an Image resource is not found.  However, you need to have the background flag set if your Image source is an absolute URL.

The following code will throw an exception if the resource is not on the classpath

        Image badImage = new Image("images/NOTFOUND.png");

A stack trace will look something like this

Caused by: java.lang.IllegalArgumentException: Invalid URL or resource not found
at javafx.scene.image.Image.validateUrl(Image.java:1110)
... 11 more

Similar code using an absolute URL will fail without throwing an error.  If using an ImageView, this results in either a blank area where the images should be shown or nothing, depending on the container.


Wednesday, April 26, 2017

Kotlin RadioButtons and Enumerated Types in TornadoFX

A previous post showed how to create a JavaFX property based on an Enum linked to a set of RadioButtons.  Selecting a RadioButton changed the Enum property.  Changing the Enum property selected (and de-selected) a RadioButton.  This Kotlin code shows a recent enhancement in  TornadoFX 1.7.4 which wraps this functionality up using an extension function.

An example usage of this new function follows.


Tuesday, April 25, 2017

JavaFX RadioButtons and Enumerated Types

In JavaFX, RadioButtons are usually added to a ToggleGroup to make the selections mutually exclusive.  The RadioButton selection can be bound as a property to another BooleanProperty field.  That pairing also supports bindBidirectional() such that the RadioButton control can update the field and the field can update the control.

You may want to bind the RadioButton selection to an enumerated type.  Say, you have an enumeration ChoiceType with 3 values.  You want to map each of those 3 values to a RadioButton.  Moreover, you'd like to maintain a single field of ChoiceType for use in a model component.