I have a java application (1.4.2) that uses 2 JFrames.
The first is Modal=true and appears on top of the second JFrame.
The first JFrame allows the user to "open" a file. Once the file is ready to be displayed, the JFrame is set to setModal=false, and this.dispose() 'd of.
This leaves only the second JFrame on the screen. However, I can't interact with it. The code does not throw any errors and appears to run perfectly fine. BUT I can;t interact with the second JFrame. The ONLY way to exit the JFrame is to hit the stop button on my development envirnment. I literally cannot stop the JFrame by clicking the close button, because I can't even interact with that portion of the 开发者_JAVA百科JFrame.
Any thoughts?
I didn't know you could toggle modality. Create a FileChooser in a modal dialog and simply dispose of the dialog when you are done.
I just ran into this problem myself. It turned out that I had unintentionally set the enabled attribute of my JFrame to false. Make sure that your JFrame is enabled whenever you want the user to be able to interact with it:
jFrame.setEnabled(true);
The Javadoc for the setEnabled method says, "Disabling a heavyweight container prevents all components in this container from receiving any input events," which explains why Wooooo and I weren't able to interact with our JFrames at all.
精彩评论