I'm making a program for attendance monitoring. A part of the program will read from an excel file. That excel file contains many sheets and each sheet contains the schedule of a professor. 

This is how that part should run. It will iterate through the sheets of the excel file. Then it will check first if the professor that owns the schedule is already in the database. If yes, the schedule will be added to the database. If not, a swing jframe will show to add that professor in the database. 

What I want to know is, when the jframe shows up, how can I pause the reading of the excel file and resume it after clicking the OK button in the jframe? I tried using wait() but the jframe freezes.

Thanks in advance