5

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 a JDialog, but that did not disable the other frame. I also looked at the other post about this, which suggested to make it a JDialog but it still does not work. I really need help doing this please. thanks. This is the codeIi am using to make the JDialog, is their any problems with it?

editDialog=new JDialog(IntroScreen.frame);

IntroScreen.frame represents the "main" frame.

alexvetter
  • 1,998
  • 2
  • 16
  • 42
Captain Gh0st
  • 177
  • 1
  • 3
  • 11

2 Answers2

11

You have set for JDialog#setModal or JDialog#ModalityTypes, maybe with Dialog.ModalityType APPLICATION_MODAL

mKorbel
  • 109,525
  • 20
  • 134
  • 319
4

If you want to use multiple JFrames 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().

alexvetter
  • 1,998
  • 2
  • 16
  • 42
  • Thank you sir, I have no idea how I didn't find this method when I was going through the methods. -__- THANKS. – Captain Gh0st Mar 09 '12 at 00:27
  • 2
    You 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. – Andrew Thompson Mar 09 '12 at 02:04