Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable JFrame when a new JFrame is opened

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.

like image 532
Captain Gh0st Avatar asked Mar 09 '12 00:03

Captain Gh0st


People also ask

How do I turn off JFrame automatically?

setDefaultCloseOperation() method to change the default behavior option of JFrame responding to the window closing event. Select the EXIT_ON_CLOSE option will terminate the application immediately. Of course, when the application is terminated, all frames will be closed automatically.

How do I close a JFrame without exiting?

DISPOSE_ON_CLOSE -- The frame will be closed and disposed but the application will not exit. JFrame. DO_NOTHING_ON_CLOSE -- The frame will be closed but not disposed and the application will not exit.

What does JFrame setVisible do?

The setVisible(true) method makes the frame appear on the screen. If you forget to do this, the frame object will exist as an object in memory, but no picture will appear on the screen.

What is the difference between JFrame and JDialog?

JFrame is a normal window with its normal buttons (optionally) and decorations. JDialog on the other side does not have a maximize and minimize buttons and usually are created with JOptionPane static methods, and are better fit to make them modal (they block other components until they are closed).


1 Answers

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

like image 104
mKorbel Avatar answered Sep 30 '22 16:09

mKorbel