views:

46

answers:

2

Hello everyone, I am not sure if I have set the right title for this post - so it is possible that there's already a post for what I am looking for, if that's the case feel free to close this and redirect me - what I am trying to do is this:

When a JFrame is poped the user not to be able to click anywhere else in the gui unless that window is closed, hopefully even throwing that annoying "DING" error sound message much like in netbeans when a "Customize Code" window is open and it's not letting you do anything outside it before it's closed.

Thanks in advance!

+5  A: 

JFrame shouldn't be popped as long as you don't want two standalone (top-level) applications running at once, that's why JFrames can NOT be modal. What you probably want is a JDialog set to modal (will even make that annoying sound).

cypher
I am not exactly sure I get your point. I pop a `JFrame` to add a lot of input from the user, which cannot be done with a JDialog. So you are telling me that I cannot make a JFrame have this attribute? Is that 100%?
devilwontcry
Why exactly couldn't it be done with JDialog, which is made for DIALOGS with user? JFrames are used as containers for top-level applications. That means they are not supposed to have a parent of some sort and therefore can't be made modal (that's the reason why they don't have the "modal" attribute. I'm not saying that I am sure it can't be done anyhow, I'm just saying that it's not supposed to.
cypher
Well JDialog is just too small and uncustomizable to the extent I need it to be, that's the reason I am trying it with a JFrame. I understand your point though. I guess I'll wait to hear some more opinions aswell. Thanks
devilwontcry
JDialog gives you just as much flexibility as a JFrame: You can make the window as big/small as needed and do pretty much whatever you would normally do in a JFrame. The only real difference between them is the fact that JDialog supports modality.
BCunningham
Oh... I didn't know that. I might as well try it then! Thanks for the info mate!
devilwontcry
A: 

Create the JFrame as a seperate thread so that you will have focus to the current window.

Prav
Seperate Thread, meaning?
devilwontcry