• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JDialog.DO_NOTHING_ON_CLOSE doesn't work

 
Ranch Hand
Posts: 255
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


I expect the line
textEditFrame.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
to make the textEditFrame not closeable when the user clicks the X to close the window. However, when the user clicks X to close the window, the window closes. What should I do to make textEditFrame not closeable by the user?
 
Ranch Hand
Posts: 4632
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
> What should I do to make textEditFrame not closeable by the user?

you need to understand how modality works

nothing *after* setVisible(true) will be processed until the dialog is disposed.
so, what do you have after setVisible(true)?
 
Kevin Tysen
Ranch Hand
Posts: 255
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Oh, I see. Once .setVisible() is called on the JDialog, nothing in that thread will execute until the JDialog is disposed. Is that right?
I just switched the .setVisible() and the .setDefaultCloseOperation() lines and got the desired results.
Thank you.
 
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
> Once .setVisible() is called on the JDialog, nothing in that thread will execute until the JDialog is disposed. Is that right?

Correct, if the dialog is modal-true.

A common problem is adding listeners, after the call to setVisible(true).

 
reply
    Bookmark Topic Watch Topic
  • New Topic