• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

need to make a window modal

 
Ranch Hand
Posts: 510
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 :-)
 
what if we put solar panels on top of the semi truck trailer? That could power this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic