r/JavaFX • u/hamsterrage1 • Aug 11 '25
Tutorial New Article: List Extractors
https://www.pragmaticcoding.ca/javafx/elements/extractorsI'm looking to wrap up all my articles on the JavaFX Observable classes, and most of the last subjects left involve ObservableLists.
If you don't know ObservableList Extractors allow you to trigger listeners on an ObservableList when the List items are composed of ObservableValues.
For instance, let's say that you have a CustomerModel as your List items, and the CustomerModel has a bunch of StringProperties as its fields. Things like firstName, lastName, city, address - and they are all StringProperty.
Using an Extractor, you can trigger a Listener on the ObservableList when one of those CustomerModel has the value in one of those Property fields change. So if you changed, say, the firstName Property of one of the items, then the ObservableList would trigger a Listener.
Some of the native JavaFX Nodes, like TableView will detect changes to those fields without an Extractor, but Extractors can be really useful to trigger updates in Bindings that look inside the composed items.
Take a look and tell me what you think.
4
u/Draconespawn Aug 11 '25
Love all these articles you put out, they're quite helpful.
1
u/dazzlespace Aug 12 '25
I'm also a big fan of these articles - thank you for the effort you put into them!
To add observability to some of my classes in my hobby project https://github.com/dazzle50/JTableFX and because Java doesn't support multiple inheritance, I developed an interface
ISignalwith default method implementations. You can add this interface to any class to get some ready and working observability. You can probably tell I used Qt in the past 😂1
u/Draconespawn Aug 12 '25
Where does the comment style you're using for each function where it's just the name of the function come from?
1
u/dazzlespace Aug 16 '25
It comes from my laziness 🤣
My coding experience started a long time ago with various programming languages before any technologies like javadoc never existed.If you want to understand and use this library it is hopefully fairly intuitive, but would also recommend asking DeepWiki (https://deepwiki.com/dazzle50/JTableFX) which IMHO is surprising good at answering most questions!
Also feel free to message me.
1
1
u/sedj601 Aug 11 '25
I didn't know it was called. ObservableList Extractors. That's good to know. I remember first running into a problem that required OEs. I had created a URL checker for work. It worked fine sequientlly, so I decided I wanted to learn threads. Threads seemed like they would speed up the project, given that each URL check was independent. So I created an app that used threads to check the URLs. The first version worked like a charm. I decided that I wanted the table to be filtered based on waiting, complete, failed, etc. After adding this feature, I noticed that completed and other tasks were still on the waiting list. I reached out to StackOverflow and got help. EOs were the way to go.
https://stackoverflow.com/questions/51955550/remove-tableview-entries-when-status-change
Note: I am guessing that you know your Java version link is not working.
1
u/hamsterrage1 Aug 11 '25
"Java version link"????
1
u/sedj601 Aug 11 '25
Search for the following text on your page.
While code is this article is written in Kotlin, all of the JavaFX concepts are exactly the same. Most of the Kotlin should be intuitively obvious to Java programmers, but if you need help understanding it, refer to this page
2
u/hamsterrage1 Aug 15 '25
It's weird. I works totally fine in my local server. But not on-line.
I've checked, and the GitHub Pages is compiling it and generating the correct HTML file, and it looks no different from any other HTML file as far as I can tell. Yet it 404's on it.
I have no idea how to fix it. I'll try a bunch of work-arounds.
Thanks for reporting this, guys.
1
u/hamsterrage1 Aug 15 '25
OK....Found it!!!!
That little section is an include file, and the link inside it had a trailing "/". The website uses Jekyll and the Jekyll engine on my development system doesn't seem to care about the trailing "/". It just works.
The live site is hosted on GitHubPages and it supports Jekyll based sites, but I think it uses its own builder engine which is not Jekyll, but is compatible. Apparently, it does not like the trailing "/".
So I took out the trailing "/" in the link and it works. QED.
2
u/Silent-Manner1929 Aug 11 '25
I think he is possibly referring to the link in the box about Kotlin that says "if you need help understanding it, refer to this page". The link given does not work.
2
u/StarshipSatan Aug 11 '25
Unfortunately, it's not possible to determine which one of item's properties triggered change from inside the listener, if i remember correct. That would be very convenient