This question is so obvious, and I am sure that it is so easy to solve that I wonder why no simple and easy to understand answer hes been posted yet. I’ve found answers explaining how to create a *new event, changing the event direction, -bubble, etc. However, I have not found a Q/A regarding catch a signal and then bounce it off to the user class, and then to a class that the is user of that user class and so on and so forth. Having said that, here is my question.
My class, ClassOne
, receive the signal of a button and then has to pass that signal to ClassTwo
, which in turn passes the signal to ClassThree
, how that heck do I do this in JavaFx.
Please note that the class must not fire a new event, but the same event that has been caught.
Below is a grammatical explanation of what I am trying to do.
Any help, and I mean any input would be most appreciated.
public class MyBoxedButton extends HBox {
private Button btn;
MyBoxedButton(){
// Initialization of all the objects
btn = new Button();
//catch the event emitted by the button
btn.setOnAction((ActionEvent e) ->{
// fire/emit the same received event
?????
});
}
}
/*
This class catches the event emitted by MyBoxedButton and then passes it to ClassThree,
but this does not work, how then can I catch the event and then re-emit it.
*/
class ClassTwo(){
private MyBoxedButton mbb;
public ClassTwo(){
mbb = new MyBoxedButton();
//catch the event emitted by MyBoxedButton
????
// re-emit the caught event
????
}
}
/*
This class catches the event emitted by ClassTwo.
The exersice is ment to show how the messages flow
form one object to a next and then to a next, so on and so forth.
*/
class ClassThree(){
private ClassTwo c2;
public ClassThree(){
c2 = new ClassTwo();
//catch the event emitted by MyBoxedButton
????
// re-emit the caught event
????
}