I recently had to turn a JFrame into a JDialog. This means transforming a regular window into a dialog. In turn, this means blocking the main application window until the user does something in the newly created dialog (also known as "modal dialog"). It's actually quite easy to do. Even though at first I was tempted to start creating a new dialog from scratch, it turns out it's just a simple change in a few lines of code.
Here is an extract from my JFrame code:
JFrame mainFrame = new JFrame("Settings");
buildContent();
mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
mainFrame.pack();
mainFrame.setSize(1200, 900);
mainFrame.setLocationRelativeTo(null);
mainFrame.setVisible(true);
And how it looks like after conversion to JDialog (I only changed 2 lines of code, those in red):
JDialog mainFrame = new JDialog(this.appFrame,"Settings",true);
buildContent();
//mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
mainFrame.pack();
mainFrame.setSize(1200, 900);
mainFrame.setLocationRelativeTo(null);
mainFrame.setVisible(true);
You probably want to avoid JFrame.EXIT_ON_CLOSE but this is how it was implemented. You may also want to do some other checks, like making sure appFrame is indeed set to the main application frame. And maybe you don't want the dialog to be that large on the screen. But for a quick JFrame to JDialog conversion, this should work ok.