0

How to close a secondary stage, which is utilized as an auxiliary window? So I have a primaryStage used as the UI platform and occasionally I need to open a secondary window which is pretty straight forward, but to close it in a method is not clear.

Here's how secondary stage is engaged:

val ivbox = new VBox(children = new Label("Create New Album"))
val stackpane = new StackPane()
sp.children = Seq(ivbox)

val secondstage = new Stage() {
  title = "second stage"
  scene = new Scene(stackpane, 450, 150) {
    stylesheets += getClass.getResource("uistyle.css").toExternalForm
  }
  x = myproto.stage.x.value + 200  // position in relation to primaryStage / scene
  y = myproto.stage.y.value + 100  //
}

In JavaFX I found this clip:

private void closeButtonAction(){
    Stage stage = (Stage) closeButton.getScene().getWindow();
    stage.close();
}

Not clear how to come by in ScalaFx?

1 Answers1

0

There is no difference in ScalaFX. You close stage using close(). Code is exactly the same in ScalaFX:

stage.close()
Jarek
  • 1,513
  • 9
  • 16