Answer the question
In order to leave comments, you need to log in
How to transfer data from one class connected to fxml to another connected fxml?
Kind
Here I asked how to split the controls into parts How to split the code in javafx into several controls?
Now the question arose, how can I transfer data from one control to another. those.
public class Main extends Application implements Initializable
public class RadioButtons implements Initializable {
<fx:include source="radio_button.fxml" fx:id="radioButtonLayout"></fx:include>
<AnchorPane xmlns="http://javafx.com/javafx"
id="radio_buttons_pane"
xmlns:fx="http://javafx.com/fxml"
fx:controller="controller.RadioButtons"
prefHeight="400.0" prefWidth="600.0">
.....
</AnchorPane>
public class RadioButtons implements Initializable {
public RadioButtons() {
}
@FXML
RadioButton radio1, radio2;
.....
}
public class Main extends Application implements Initializable {
@FXML
Button addProduct;
@Override
public void initialize(URL location, ResourceBundle resources) {
Observable<String> observable;
observable = Observable.just("test");
addProduct.setOnAction(event -> {
new RadioButtons().addDB(observable); //тут я не могу писать new, т.к. класс уже существует, при старте программы
});
}
public class RadioButtons implements Initializable {
public void addDB(Observable observable) {
Observer<String> server = new Observer<String>() {
@Override
public void onSubscribe(Disposable disposable) {
}
@Override
public void onNext(String s) {
System.out.print(s);
eventBus();
}
@Override
public void onError(Throwable throwable) {
}
@Override
public void onComplete() {
}
};
observable.subscribe(server);
}
}
Answer the question
In order to leave comments, you need to log in
I don't see a solution for my case, I need to get a class referencepublic class RadioButtons implements Initializable
get a link to the nested controller and use this link in the button handler of the button.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question