I spent a lot of time with this problem trying different solutions without success. I want to sent a count value (Buttons clicks) from class ViewPart2 to class ViewPart1. In ViewPart1, I want to update label text.
public class Test extends Application {
    public static void main(String[] args) {
        launch(args);
    }
    @Override
    public void start(Stage stage) throws Exception {
        BorderPane root = new BorderPane();
        Scene scene = new Scene(root, 300, 200);
        stage.setScene(scene);
        stage.show();
        new ViewPart1().createGui(root);
        new ViewPart2().createGui(root);
    }
}
public class ViewPart2 {
    private int count = 0;
    public void createGui(BorderPane root) {
        Button btn = new Button("Click me!");
        root.setLeft(btn);
        btn.setOnAction(event -> {
            count++;
            new ViewPart1().setCount(count);
            // how can I send count value to ViewPart1 and update label text
        });
    }
}
public class ViewPart1 {
    private int count;
    public void createGui(BorderPane root) {
        Label lbl = new Label("-");
        root.setCenter(lbl);
        lbl.setText(count + "Clicks");
    }
    public void setCount(int count) {
        this.count = count;
    }
}
 
     
    
