Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JDialog in front its JFrame parent

I want to create in Java Swing a JDialog which, when it's open, its parent window cannot be accessed (just like when you open the file explorer dialog in Microsoft Word). Is there any method in the JDialog class that provides this behaviour?

like image 909
Anto Avatar asked Oct 23 '25 13:10

Anto


1 Answers

use JDialog.setModal(true) before setting dialog visible

JDialog yourdialog = ...

yourdialog.setModal(true);
...

yourdialog.setVisible(true);
like image 157
Jan Wegner Avatar answered Oct 25 '25 02:10

Jan Wegner



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!