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 ...

Wednesday, August 23, 2017

Setting the Pivot Point in a JavaFX ScaleTransition

This article shows how to use a JavaFX ScaleTransition to expand a container of controls from nothing to its full dimensions.  While this is especially easy to do if you are content to scale the container outward from the center, an extra transformation is needed to expand the container from the top left, in this case next to the originating control.

When working with animations, I like to use the transformations as much as possible over object properties like width and height.  That helps to preserve the integrity of the layout.  For example, a zero-width Node might cause other items to shift undesirably.  If keeping unaffected Nodes in their original place is important, prefer ScaleTransition to animating width and height and prefer TranslateTransition to x and y.

Sliding Content In With JavaFX TranslateY

A reader asked about sliding content into a screen via animation.  This blog post uses a Pane to show a slide which is animated in using the slide's translateY property. I used a Pane because it does not attempt to resize the child's contents.

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.