JavaFX Java GUI Tutorial – 7 – Closing the Program Properly

Facebook –
GitHub –
Google+ –
LinkedIn –
reddit –
Support –
thenewboston –
Twitter –






31 responses to “JavaFX Java GUI Tutorial – 7 – Closing the Program Properly”

  1. addison davis Avatar

    please i have a question….yeah when i insert a record into my database and get a pop up message,,that record saved sucessfully.when i close the message or press on ok to close the message. it hide my forms…immediately i close the message ,,,,it hide my forms in the taskbar.please do you know the codes that will unhide my forms when i press on ok or close.util i my self hide the form or close my form (javafx)

  2. Mr Daniel Avatar

    Omg thanks, needed this

  3. Immortal Legends Avatar

    Pheraps the code is lengthy but the code ConfirmBox.display was not working in my IDE so i wrote this one….

    public class Main extends Application{
    static String ans;
    static String a;
    public static void main(String[] args){

    public void start(Stage primaryStage) {
    Stage st = new Stage();
    st.setTitle("Main Window");
    Button b = new Button("Click ME");
    a =cls();
    if(a == "yes"){

    StackPane sp = new StackPane();
    b.setOnAction(e-> {
    a = cls();
    if(a =="yes"){
    Scene sc = new Scene(sp , 400 , 300);
    public String cls(){
    Stage st = new Stage();
    st.setTitle("Alert Box");
    Button bt = new Button("YES");
    Button tb = new Button("NO");
    VBox vx = new VBox(20);
    Label lb = new Label("Are you sure you want to exit");
    vx.getChildren().addAll(lb , bt ,tb);
    bt.setOnAction(e-> {
    ans = "yes";
    ans = "no";
    Scene sc = new Scene(vx , 250 , 200);

  4. Ihor Bandrivchak Avatar

    thank you very much)

  5. Ditte Jørgensen Avatar

    You are really helping us out in our semester project at uni. Thanks!

  6. J Tiwa Avatar

    Tutorial on how to create one window and two scenes but two scenes in different classes.

  7. Carlos Axel Cruz Bon Avatar

    what if user try close the window by clicking on taskbar -> close? any idea?

  8. kenn nacion Avatar

    What happens if you click the X button on the alertbox instead of no?

  9. Scott123180 Avatar

    press ctrl-d to duplicate line instead of having to copy paste

  10. yağız yalçıntaş Avatar


  11. Muhammed Sami Avatar

    why confirmbox does'nt work ?

  12. Jinxin Pan Avatar

    how do you actually save a file though…. does he have a tutorial on that? I see none in this series.

  13. Osgaldor Storm Avatar

    Hi Bucky! I have a request. Would you do a tutorial on how to create a basic text editor in JavaFX? That would help me a lot. Thanks Bro! Top notch tutorial, as always Thumbs way up!

  14. Rocky Parmar Avatar

    Please make a tutorial of adding a background on the scene

  15. TheMhollow2 Avatar

    Again, because logic in previous video won't, neither will this. It uses the confirm box class from the previous video. Thus when you run this and click no, it's still just going to close anyway I think because confirm box class always returns true. I'd love someone to point out what I've done wrong.

  16. Raiden XT Avatar

    how did the program run? isnt "window" out of scope?

    nvm, i didnt see that it was declared outside main

  17. Hunter Stephens Avatar

    How would you format the syntax for the setOnCloseRequest() if I were not using lambdas, and instead the handle() function?

  18. Simone Bogni Avatar

    I found these tutorials yesterday and I love them. You are simply wonderful. I love how funny you make them :'D

  19. Daniel Däschle Avatar

    Why you don't override the method stop()?

  20. lorenc islamaj Avatar

    The return of the method display will give a Boolean value in any case and is not going to wait to click the Yes or No buttons.
    And bay default is false.
    So the first time is not going to work for the yes button.

  21. Stillbornsavior Avatar

    I get a null pointer exception with the code at around 1 minute. Wont close but it does print "saved" in the terminal. Any help?

  22. Mikkel Bytoft Avatar

    quick question, why is Boolean capitalized, is it not usually all lower case?

  23. Vahe Gharibyan Avatar

    Its a liltte bit of different from android, I realy didn't understand why we should pass child view on parent child ?
    layout.getChildren().add(…some view…) , instead of layout.addView(..some child view..). How is it working ?

  24. Prince Gupta Avatar

    how you changed the theme of intellij idea IDE

  25. Harout Tatarian Avatar

    Great videos keep it up!

  26. José Duarte Avatar

    What would help if you used the close X in the ConfirmBox?

  27. Stepn2 Math Avatar

    Hello Bucky I have been following you for some time now. I would love to see you open a tutor session somewhere where for instance you provide some trial videos and then paid lessons. Live sessions would also be a great added bonus that I would be happy to pay for. I enjoy the way you teach and also learn more from your videos than from school and that along say a lot about our education system. In closing I am thankful for all your videos and my sector of interest would be learning how to build a live chat system where I can one day tutor others. If you have any lessons about sockets or other ways I could build a multichatroom that would be awesome. Keep up the great work

  28. David Henley Avatar

    What's wrong with using the Overridden stop() method?

  29. Qazi Jalil Avatar

    kindly make a tutorial over javafx about tables, binding, properties and to link all of them in one I meant four videos for all of it thank you in advance really want to learn these topics because they are cote topics of javafx

  30. dir3mad Avatar

    Great tutorials mate, there's only one flaw in your videos, font size 😀

Leave a Reply

Your email address will not be published. Required fields are marked *