Tuesday, December 5, 2017

JAVAFX - How show new modal dialog

@FXML
private void btnAboutAction( ActionEvent event ) throws Exception {
 
  /* read form from .fxml */

  FXMLLoader fxmlLoader = new FXMLLoader( getClass().getResource( "FAbout.fxml" ) );

  /* get form */

  Parent form = (Parent) fxmlLoader.load();

  /* set dialog properties */

  Stage stage = new Stage();
  stage.initModality( Modality.APPLICATION_MODAL );
  stage.setResizable( false );
  stage.setTitle( "About" );  

  /* show it in screen center */

  stage.setScene( new Scene( form ) );  
  stage.centerOnScreen();
  stage.show();
}

No comments:

Post a Comment