Fork me on GitHub


Posts tagged ReactFX

Animated Transitions Made Easy

In the previous post I presented ReactFX’s Val as an improved ObservableValue. In ReactFX 2.0 Milestone 3 it got even better: changes to values can be animated seamlessly.

Val<T>: a better ObservableValue

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.

Measuring FPS with ReactFX

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.

Detecting when the mouse stays still over a node

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.

Timers in JavaFX and ReactFX

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

How to ensure consistency of your observable state

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.

ReactFX's general stream combinator: State Machine

In ReactFX, we work with event streams. It provides various operations on event streams such as filter, map, merge, zip, combine, 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.

Combining ReactFX and asynchronous processing

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.

Trigger processing after a period of inactivity

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.