I am writing a program with JavaFX and Scene Builder
There is a main class Main which starts the program and opens the main window of the controller (Controller).
public class Main extends Application { public static void main(String[] args) { launch(args); } @Override public void start(Stage primaryStage) throws Exception { try { Parent root = FXMLLoader.load(getClass().getResource("/card/card.fxml")); Scene scene = new Scene(root, 1600, 600); primaryStage.setScene(scene); scene.getStylesheets().add(getClass().getResource("style.css").toExternalForm()); primaryStage.initStyle(StageStyle.UNDECORATED); primaryStage.setMaximized(true); primaryStage.setResizable(true); primaryStage.getIcons().add(new Image("card/resources/logo-icon.png")); primaryStage.show(); //adding resize and drag primary stage ResizeHelper.addResizeListener(primaryStage); //assign ALT+ENTER to maximize window final KeyCombination kb = new KeyCodeCombination(KeyCode.ENTER, KeyCombination.CONTROL_DOWN); scene.addEventHandler(KeyEvent.KEY_PRESSED, new EventHandler<KeyEvent>() { @Override public void handle(KeyEvent event) { if (kb.match(event)) { primaryStage.setMaximized(!primaryStage.isMaximized()); primaryStage.setResizable(true); } } }); } catch (Exception e) { e.printStackTrace(); } } } In the main window there is a label and also a button, when clicked, a window with another controller appears (FontController)
@FXML private Button btnFont; @FXML private Label category1 @FXML void changeFont(ActionEvent event) { try { FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("font.fxml")); Parent rootFont = (Parent) fxmlLoader.load(); Stage stage = new Stage(); stage.setTitle("Select Font"); stage.setScene(new Scene(rootFont)); stage.show(); } catch (Exception e) { System.out.println("can't load new window"); } } FontController has a label and an OK button.
@FXML private Label fontLabel; @FXML private Button btnFontOk; Please tell me how to make it so that when you click on the OK button, the text from the label of this controller is sent to the Controller and displayed in the label?
EDITORIAL:
@boneferz I pasted this code, but setController is not recognized


