Category Archives: Java

JavaFX Event Handling

I’m finding myself needing a better understanding of JavaFX UI event handling and my basic JavaFX books seem to ignore most of that aspect of the system. It looks as if the wiring of UI events is buried deep enough and the handling is automated enough that most of the time there’s no need to directly interact with events.

I need to perform an action when a given UI panel is exposed after being hidden…a simple enough activity in most cases. I expect I’ll find the right controls soon enough, just a bit surprised that they’re not talked about as directly as I’m used to.

Looking as if the easy route to this may be to name the top level pane in a given area and then attach a ‘show’ handler to that pane. Hoping this works as this would make it pretty easy to do what I need to get done.

Some links that I’m recording for later convenience (some just interesting here not directly relevant):

The charting and 3D API items are of interest, but not part of this, but I’m trying to keep notes on where things were found so that I can go back and dig deeper later…a small amount of clutter for convenience…

Java Tasks don’t do Lambdas

I was spinning a thread recently and it was pointed out to me that the environment I was working in at the time used Task (JavaFX code) for such things. My thread was being created with a Lambda expression as the action to be performed. It surprised me when I could not directly translate that to a Task.

After a bit of research I found this post discussing why that is the case (as a side-effect of the fact that Task is an abstract class). As with so many things in Java where the choice is to accept less expressive and longer winded approaches to limit language level complexity, I’m not sure I agree with the choice, but it is what it is at this point.

Adding in the anonymous local class framing isn’t a big deal and that’s clearly the way to go for this item.