0

I have an alert:

Alert alert = new Alert(AlertType.INFORMATION);
alert.setTitle("Loading");
alert.setHeaderText("Loading Dialog");
alert.setContentText("Please wait while we load.");

If I run

alert.showAndWait();

it works as expected. However, if I run

alert.show();

I get the followng:

enter image description here

I need to use show because it's a loading dialog and my content can't load if I use showAndWait.

Mooseman
  • 18,763
  • 14
  • 70
  • 93
  • What, exactly, do you mean by "it's a loading dialog"? – James_D Apr 24 '17 at 19:15
  • @James_D It's meant to inform the user that content is loading while I'm pulling data in the background. I call `alert.close();` after my data is loaded. – Mooseman Apr 24 '17 at 19:19
  • So it looks like you are not actually loading the data in the background, but are doing so on the FX Application Thread. That would prevent the UI from being rendered and give you exactly the blank screen you show. Of course, without seeing any code, it's impossible to be sure. I recommend you [edit] your question to include a [MCVE]. – James_D Apr 24 '17 at 19:21
  • @James_D That is correct, I am using the FX application thread. That said, is there a way to delay the call to the data fetch until the alert is rendered? – Mooseman Apr 24 '17 at 19:25
  • Um, well... don't use the FX Application Thread for long-running tasks. Doing that will prevent the scene from being rendered and make the UI unresponsive. Perform the long-running task on a background thread. See (among many, many examples on here): http://stackoverflow.com/questions/30249493/using-threads-to-make-database-requests – James_D Apr 24 '17 at 19:26
  • @James_D Threaded and working, thanks! Please feel free to post an answer so I can accept it. – Mooseman Apr 29 '17 at 10:22

0 Answers0