I was not sure which forum this really belonged in so I am posting here. I have a menu item for printing. However, before calling the print method, I need to get an option from the user. So within the menu action handler I launch the option dialog with a countdown latch:
PrintType is the class that manages the option dialog.
The objective is that when the user clicks the submit button, the selected radio button is saved, the latch decremented and the window closed so it will proceed to the print dialog. Without the latching, the option dialog and the print dialog come up together and the option dialog, although properly displayed, cannot be used while the print dialog is up. I want to reverse that. I want the option dialog to happen first thus the reason for the latch. Unfortunately, while the option dialog comes up with the latch, it is not fully displayed. It has the same background as the underlying window and the buttons and labels are never displayed. At that point the application is hung and the only way to close it is to kill it from the OS. I also tried using invokelater to set up a separate thread but got the same results. Obviously something somewhere is waiting for something to happen that prevents the dialog window from even being completely displayed. Can someone spot what I am doing wrong? TIA.
Concurrency in Swing. In other words, long lasting or blocking code should never be performed directly inside event handling methods but you should use a SwingWorker, thread (with EventQueue.invokeLater for notifying the GUI) or SecondaryLoop instead.