src/main/java/com/xdavide9/calculatorfx/CalculatorFXController.java
@FXML
    protected void onFnPressed(ActionEvent e) throws IOException {
        id = updateId(e);
        log.info("Pressed: {}", id);

        onLabel = label.getText();
        if (status(onLabel) == -1) return;

        FXMLLoader fxmlLoader;
        onLabel = label.getText();

        if (isOnSimple) {
            isOnSimple = false;
            fxmlLoader = new FXMLLoader(CalculatorFXApplication.class.getResource("complexOperations.fxml"));
        } else {
            isOnSimple = true;
            fxmlLoader = new FXMLLoader(CalculatorFXApplication.class.getResource("simpleOperations.fxml"));
        }

        Stage stage = (Stage) ((Node) e.getSource()).getScene().getWindow();
        Scene scene = new Scene(fxmlLoader.load());
        scene.getStylesheets().add(Objects.requireNonNull(CalculatorFXApplication.class.getResource("darcula.css")).toExternalForm());
        CalculatorFXController controller = fxmlLoader.getController();
        //injecting the label's text through the controller each time you switch scene because it cannot be made static
        controller.label.setText(onLabel);
        //injecting focus on the fn button to prevent an annoying effect otherwise occurring
        controller.fnButton.requestFocus();
        stage.setScene(scene);
        stage.show();
    }
/**
     * Switches to a different scene where more
     * complex functions are present.
     */
Switches to a different scene where more
complex functions are present.
Switches to a different scene where more complex functions are present .
@FXML
    protected void onFnPressed(ActionEvent e) throws IOException {
        id = updateId(e);
        log.info("Pressed: {}", id);
        onLabel = label.getText();
        if (status(onLabel) == -1) return;
        FXMLLoader fxmlLoader;
        onLabel = label.getText();
        if (isOnSimple) {
            isOnSimple = false;
            fxmlLoader = new FXMLLoader(CalculatorFXApplication.class.getResource("complexOperations.fxml"));
        } else {
            isOnSimple = true;
            fxmlLoader = new FXMLLoader(CalculatorFXApplication.class.getResource("simpleOperations.fxml"));
        }
        Stage stage = (Stage) ((Node) e.getSource()).getScene().getWindow();
        Scene scene = new Scene(fxmlLoader.load());
        scene.getStylesheets().add(Objects.requireNonNull(CalculatorFXApplication.class.getResource("darcula.css")).toExternalForm());
        CalculatorFXController controller = fxmlLoader.getController();
        controller.label.setText(onLabel);
        controller.fnButton.requestFocus();
        stage.setScene(scene);
        stage.show();
    }
@ FXML protected void onFnPressed ( ActionEvent e ) throws IOException { id = updateId ( e ) ; log . info ( "Pressed: {}" , id ) ; onLabel = label . getText ( ) ; if ( status ( onLabel ) == - 1 ) return ; FXMLLoader fxmlLoader ; onLabel = label . getText ( ) ; if ( isOnSimple ) { isOnSimple = false ; fxmlLoader = new FXMLLoader ( CalculatorFXApplication . class . getResource ( "complexOperations.fxml" ) ) ; } else { isOnSimple = true ; fxmlLoader = new FXMLLoader ( CalculatorFXApplication . class . getResource ( "simpleOperations.fxml" ) ) ; } Stage stage = ( Stage ) ( ( Node ) e . getSource ( ) ) . getScene ( ) . getWindow ( ) ; Scene scene = new Scene ( fxmlLoader . load ( ) ) ; scene . getStylesheets ( ) . add ( Objects . requireNonNull ( CalculatorFXApplication . class . getResource ( "darcula.css" ) ) . toExternalForm ( ) ) ; CalculatorFXController controller = fxmlLoader . getController ( ) ; controller . label . setText ( onLabel ) ; controller . fnButton . requestFocus ( ) ; stage . setScene ( scene ) ; stage . show ( ) ; }
Switches to a different scene where more
 complex functions are present.
Switches to a different scene where more complex functions are present .
//injecting the label's text through the controller each time you switch scene because it cannot be made static //injecting focus on the fn button to prevent an annoying effect otherwise occurring