I have two Java classes. Let's take it as A & B
I have a Label B1 in class A and when I click 'B1', I want the next java FX class to be opened.
I tried using this code, but it throws a series of exceptions and I couldn't achieve the task.
CLASS A :
label.setOnMouseClicked(new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent event) {
Application.launch( B.class );
}
});
CLASS B :
public class B extends Application{
public void start(Stage primaryStage) throws Exception {
VBox vb = new VBox();
Label sub = new Label("TEST");
primaryStage.initStyle(StageStyle.UNDECORATED);
Scene scene = new Scene(vb, 630, 500);
primaryStage.setScene(scene);
vb.getChildren().addAll(sub);
primaryStage.show();
}
}
P.S.
I am not using FXML to add style to the scenes.