• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

using hide() in javafx doesn't work (eclipse)

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello all,

I have created a class called App that extends Application (JavaFX). In it, I have 2 stages that are displaying a few buttons. This App class is instantiated in main then passed as an argument to another class/thread called Controller (a has-a relationship). Once Controller receives an event, it calls app.hideGUI(); the contents of the function are:



Also, in the App class I have the following:



However, this does not work. It either crashes or simply does not hide the stages. Please advice me on why and how to fix this.

Thank you
 
Rancher
Posts: 387
30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
> Once Controller receives an event, it calls app.hideGUI();

I have no idea how your controller receives an event. I am guessing the event is being sent to the controller on a thread which is not the JavaFX application thread.
If this is the case you need to surround your code in a Platform.runLater construct to allow that code to execute on the JavaFX application thread.


I don't know if the above is your issue or your only issue.

Note that if you hide all the stages, the JavaFX runtime will exit, so if you want to temporarily hide the stages and then at a later time show them again, then you need to keep the platform running by invoking Platform.setImplicitExit(false); before you hide the stages. If you do that you will eventually need to explicitly exit the JavaFX platform at some stage when your application is supposed to shut down. You can do this by calling Platform.exit();
 
WHAT is your favorite color? Blue, no yellow, ahhhhhhh! Tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic