stefanie ohm wrote:I found similar questions and concerning answers to this kind of problem but this was not helpful for me. My specific problem is: In the code below the program runs and goes directly to the last line “system.out.println(“to this point”)”.
That's how Swing (and AWT) works. When you show a frame (by calling
setVisible(true)), this does not block the current
thread - it just continues. (Note that modal dialogs, like the file chooser dialog, will block the current thread, but no other windows will.)
I want that it waits until one pressed the button (buttonsav) to choose some files. Then after successful done it should go to the last line System.out.println("to this Point"). Later these files are processed. The program cannot run without these files. So, how to let the program wait for buttonclick.
That's what the button's action listeners are for (there can be multiple). Move the
println statement inside your action listener code, like Swastik has shown.