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.
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, April 26, 2017
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.
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.
Monday, March 27, 2017
Kotlin Elements in TorandoFX Type Safe Builders
While the Kotlin-based TornadoFX framework supports many styles to construct a JavaFX UI, the Type Safe Builders are preferred. Borrowing from a popular Groovy syntax, the TornadoFX Type Safe Builders are Kotlin Extension Functions that use Lambdas to write cleaner programs.
This is an example TornadoFX View which is an HBox containing three Labels.
This is an example TornadoFX View which is an HBox containing three Labels.
class GridDemosMainView : View() {
override val root = hbox {
label("Label 1")
label("Label 2")
label("Label 3")
}
}
Monday, January 16, 2017
C# WebClient Parsing JSON Array
This is a snippet of code that calls a RESTful web service and parses the JSON result. The JSON payload is a list of objects. The solution uses the .NET class DataContractJsonSerializer and an annotated DataContract.
Saturday, December 3, 2016
Kotlin Callable Reference Notes
Method references were added to Java 8 and you may already be using the double-colon (::) syntax to use a method reference as a parameter. The semantics in Kotlin are different although a change in 1.1 will address these differences.
This article presents a few examples of passing function references in Kotlin 1.0.
This article presents a few examples of passing function references in Kotlin 1.0.
Subscribe to:
Posts (Atom)