the JavaFX in the title is put into brackets, as the desired answer to this question applies to any object-oriented GUI Toolkit. For me, it is JavaFx, not because I love working with FXML-files and css (I actually code nearly every layout directly by myself instead of using FXML), but because I started to work on my Project in C# with WinForms and wanted to be able to provide my program to OSX-users.
The situtation: The program itself is a kind of Digital Audio Workstation or DAW with the classical elements of track-based editing, some cursor following the tracks that are stacked on top of each other as the music plays, some panels for editing a certain track and adding effects. All of these elements (every single track, every panel with some settings, the silder to move the displayed time interval of the tracks) are selfmade UI-classes that inherit from an Anchor Panel or a VBox or sth. like this ... They manage their own data and how this is displayed. Communciation between these elements is, especially for this kind of application, unavoidable.
Example: The silder to choose which part of the track is shown has to communicate with the VBox containing the tracks as well as with the tracks as they have to manage which elements on the track are shown. For those, who don't know how DAWs look, just an example here
The problem: All of this works pretty well, but the more distinct UI Elements (such as an effect editor, a track manager, setting panel, export panel) I have, the more confusing the code gets inside the elements, that have to communicate a lot with other elements to manage their data, look and behaviour.
What I hope for: Simply spoken: a smart way to manage all those dependencies while still maintaining encapsulation of the single UI Elements. My current code works, but it is a wild mix of ideas I had to manage those problems like using Interfaces or directly accessing one UI Element from another by giving each element a reference to the other elements it depends on. I simply want to cleanse my code and have a fixed scheme on how to deal with those dependencies before I continue putting new features into my program.
A minimal example that could be taken to answer my question would be: I have an AnchorPane that contains a panel with some settings and a VBox with my tracks. If I click "add Track" in the settings, a track should be added to the Vbox. The other way around, if I delete a track via right-click & context menu, The settings panel should show a number of n-1 instead of n tracks now. For both operations, the track has to know about the settings panel and the settings panel has to be able to access the tracks or at least the VBox.
I hope this didn't get too long and I am looking forward to your answers.
Best regards