first post here
Hoping someone might help I apologize in advance for the non code talk i'm self taught and very old.
I have a Midi signal coming from an external program into MainApp the Midi note numbers are then sent to "private void midiNoteClock(int i)(main line 47) " which then sends to my FXML Class EventHandlerController / void donkey(int i) this bit works well and i can console print the midi numbers . So i now have an Integer or String that i wish to use to do things with, but every thing I have tried doesn't create an error but then again doesn't work. For instance I might want to display the integer in a TextArea (controller line 26) or use it to increase the radius of a circle as (controller line 27) But it doesn't
The other thing i don't quiet understand is if i wanted to send a int from the EventHandlerController to the MainApp i defined final MainApp t3 = new MainApp();(controller line 13) outside of lets say a button and then use a instance inside a button. (Please look at "private void HBA9()" ) (controller line 52). But if i'm sending the other way as in "private void midiNoteClock" to " void donkey(int i)" (main line 50) where can I define a new EventHandlerController() so its outside and does execute all of the EventHandlerController ..... it doesn't let me do this without an error.
If you got this far thanks for reading; This code form part of a larger file .
I've cut it down as far as I can Here is the code: MainApp
You should not create a new MainApp inside your controller.
You already have an application instance created for you when the JavaFX application is launched, you should reuse that (or better yet, make the controller self-sufficient and independent of the application using it).
You should not create a new EventHandlerController.
You already have a controller created for you when you load an FXML file.
I'd advise moving all of the midi related stuff out of the Application.
Try to make you classes follow the Single Resposibility Principle https://en.wikipedia.org/wiki/Single_responsibility_principle of SOLID https://en.wikipedia.org/wiki/SOLID_(object-oriented_design).
The application should just implement only the Application interface of co-ordinating initializing, starting and stopping of the application and load up and display of the initial scene.
Also it is weird that your application would both implement Receiver and have a Receiver member variable.
Instead what you should do is use more of an MVC style design, where the application creates the model and the loads up the FXML view (during the process of which the FXMLLoader implicitly creates the controller and links it to the view). What the FXMLLoader won't do is wire in your model objects, to do that, you can review various options in the answer to this question: http://stackoverflow.com/questions/14187963/passing-parameters-javafx-fxml. MVC is more of a guideline than a strict rule, without knowing your domain it is a little difficult to know if the receivers should be disconnected from your controllers and part of the model or not. For instance you could have your controller implement the receiver interface if the receiver instance should be tightly coupled to an instance of a UI represented by a controller instance. If you need a more flexible design where the receiver is a seperate object which multiple controllers need to interact with, then you could shift it to be part of model which is inserted into controls either via dependency injection (e.g. gluon ignite http://gluonhq.com/open-source/ignite/) or by calling a method on the controller:
Don't catch exceptions and then log them without a stack trace otherwise you lose useful debugging info, e.g. instead of
Also, it is extremely rare that you would want to swallow an error without at least reporting it, e.g. don't write:
Things will just go wrong and you will never know.
It looks like you call donkey explicitly. That being the case, you don't need to (and should not) annotate it with @FXML. The @FXML won't actually do anything in such a case, it will just confuse somebody reading the program. @FXML is supposed to be a signal to the FXML loader that the a member variable should be injected into an FXML controller or a method should be wired to service an event handler referenced in FXML, neither of which seems to be the case with donkey.
There may be other issues with your code, they were just some things which came to mind.
//end of the world// nice comment :-)