Fork me on GitHub


Posts tagged JavaFX

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.

The Trouble with Weak Listeners

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.

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.

RichTextFX just got faster

When I started working with JavaFX almost a year ago, there was no native JavaFX code-editing control. Just like any decent programming language hosts its own compiler, I believe any decent UI toolkit should host its own IDE. And you cannot have an IDE without a code editor. It is great that JavaFX allows you to embed HTML and Javascript, but on the other hand, I found it somewhat embarassing that users of the best UI toolkit on the planet had to resort to embedding HTML to get a text editor with syntax highlighting. So I started CodeAreaFX, which evolved to RichTextFX.

Separation of View and Controller in JavaFX Controls

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.

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.

Monadic operations on ObservableValue

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.

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.