• Post Reply Bookmark Topic Watch Topic
  • New Topic

need to make a window modal

 
Michael Ku
Ranch Hand
Posts: 510
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need to make a window modal or appear to be modal. I know that the component to use for modal behavior is a Dialog. I have a framework that I inherited and it will produce a window. the problem is that users can click off of the window which produces a bad user experience. The framework cannnot be changed easily to produce a Dialog instead of Window
Does anyone have a suggestion?

Thank you
Michael
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
when the window is shown
[parentFrame].setEnabled(false);


add a windowListener, and in windowClosing()
[parentFrame].setEnabled(true);
 
Michael Ku
Ranch Hand
Posts: 510
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Michael. I will try this and let you know the results :-)
 
Michael Ku
Ranch Hand
Posts: 510
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there a reliable way to get the parent from the window I am tryin to make "modal". My app stores it away and then retrieves it, but I would be happier if my window knew its parent and I could ask it. Is this hows it is done? Also, is there a WindopwAdpater class so I do not have to implement all of the WindowListener methods myself?

Thanks
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if you create the window using the 'owner' constructor
((Frame)window.getParent()).setEnabled(false);

> is there a WindopwAdpater class...
Yes, but it's not really a question you should be putting to a forum
1) the apidocs are easy to consult
2) your IDE, type in WindowAdapter - does the color change to indicate a keyword?
 
Michael Ku
Ranch Hand
Posts: 510
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks. I did find the WindowAdapter in the API docs. It turns out that I cannot use the WindowListener. The window that I am working with is not closed by my framework but disposed of in a thread. I will figure out something

Thanks again :-)
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!