• Post Reply Bookmark Topic Watch Topic
  • New Topic

JDialog.DO_NOTHING_ON_CLOSE doesn't work

 
Kevin Tysen
Ranch Hand
Posts: 255
  • Mark post as helpful
  • send pies
  • 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?
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Likes 1
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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).

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!