I have a button made in the graphical interface of the netbeans environment. In the code itself, I have prescribed an event to occur when the button is pressed, but how can I prevent the program from going further until I click this button with the mouse?

  • 3
    I do not quite understand, do you need the main thread to stop at some event until you press the button in the NB itself? But is not it easier to put a mark and use debug mode? - Riĥard Brugekĥaim
  • What does it mean "to go no further" that the program performs the actions? - qwerty123

2 answers 2

If the GUI responds to your actions, for example, it allows you to click a button, and not “hangs”, then at that moment the program does not perform any actions, but simply waits for an event to fire.

But this is if you have not created other threads in which some actions are performed in parallel. In this case, the GUI will not hang.

    The program goes no further. It starts, executes the main () method until the end, and waits for the button (or another user action) to be pressed.