Disable JFrame when a new JFrame is opened
Solution 1
You have set for JDialog#setModal or JDialog#ModalityTypes, maybe with Dialog.ModalityType APPLICATION_MODAL
Solution 2
If you want to use multiple JFrame
s you could use the method setEnabled()
when you open the other JFrame
.
frame.setEnabled(false);
Otherwise you should go with JDialog
and its method setModal()
.
Related videos on Youtube
Captain Gh0st
Updated on June 04, 2022Comments
-
Captain Gh0st almost 2 years
I am trying to disable the "main"
JFrame
when the new frame pops up. I want it so you can not click or drag anything on that frame. I tried making the new frame aJDialog
, but that did not disable the other frame. I also looked at the other post about this, which suggested to make it aJDialog
but it still does not work. I really need help doing this please. thanks. This is the codeIi am using to make theJDialog
, is their any problems with it?editDialog=new JDialog(IntroScreen.frame);
IntroScreen.frame
represents the "main" frame.-
Hovercraft Full Of Eels about 12 yearsgosh, this has never been asked before...
-
-
Andrew Thompson about 12 yearsYou chose the 'right' answer to the wrong question. The (easy) way forward is pointed out by HFOE & mKorbel. Multiple frames will cause you more stress.