ObservableValue is the JavaFX way of representing a time-varying value, whose changes can be observed by a listener. As it is, it really is a bare bones interface. I myself have previously enriched it in two different ways: EasyBind’s
MonadicObservableValue that adds some useful operations, and InhiBeans to postpone listener notifications. Val, introduced in ReactFX 2.0 Milestone 2, integrates both these ideas and adds some more.
JavaFX bindings use WeakListeners to observe their dependencies. This reduces the need to dispose() bindings, but comes with some surprising behavior. In this post I show two kinds of problems introduced by weak listeners. In the next post, I will show how we can do better without weak listeners.
I came across this StackOverflow question about measuring frame rate in JavaFX and while James_D gave a nice solution, I still found it a little too verbose for such a simple task.
This post first really quickly introduces skins for JavaFX controls, then discusses the non-public base class for skin implementations (
BehaviorSkinBase) and its pitfalls, and finally outlines how public API for Skin implementations that encourages separation of view and controller could look. This post presents a lesson learned from my recent refactoring of RichTextFX.
Everyone has seen tooltips: the mouse enters a node, stays still for a while, and then a tooltip is displayed. JavaFX does have tooltips. They are easy to use, but not very flexible. For example, you cannot control the delay before the tooltip is shown or for how long it is shown. If you want to roll your own tooltip implementation, the first step is to detect when and where the mouse stays still.
The takeaway from this post should be that to schedule future actions in a JavaFX application you don’t need an external timer (and thus an extra thread in your application), such as
java.util.concurrent.ScheduledExecutorService. You can use Timeline or FxTimer, a convenient wrapper around Timeline used internally in ReactFX and recently exposed as public API.
In this post, I would like to make an appeal to JavaFX developers, especially library creators, to provide stronger consistency guaranties of their observable objects.
In ReactFX, we work with event streams. It provides various operations on event streams such as
reduceSuccessions. Of course these cannot cover all the use cases. In such a case, you can either extend LazilyBoundStream to implement your custom stream combinator, or you can use the state machine combinator.
We have seen previously how to use ReactFX to trigger processing after a period of user’s inactivity. In this post, we are going to make the processing asynchronous and apply its result back to the scene when complete. The example we are going to use is syntax highlighting.
EasyBind introduces MonadicObservableValue that adds monadic operations to JavaFX ObservableValue. First of all, don’t get scared by the word monadic—it just means that there are a few more operations that treat
null as “value not available.” Anyway, if you have already used Optional, this will all look very familiar.
This post shows how to use ReactFX to defer processing of user input until a specified period of user’s inactivity. This is useful, for example, to trigger spell checking or syntax highlighting after the user hasn’t typed anything for, say, 500ms. Another use-case, which we use in this post, is real-time HTML rendering of user input.