Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JDialog won't exit  RSS feed

 
Dennis Putnam
Ranch Hand
Posts: 377
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a non-modal JDialog (invokelater). When my listeners execute a 'dispose' the window closes but the process continues to run, doing who knows what. What is the proper way to exit a JDialog? TIA.
 
Les Morgan
Rancher
Posts: 767
19
C++ Java MySQL Database Netbeans IDE Oracle Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I use a flagged exit on all threads. When the thread see's the flag to dispose, it closes itself down.
Dennis Putnam wrote:I have a non-modal JDialog (invokelater). When my listeners execute a 'dispose' the window closes but the process continues to run, doing who knows what. What is the proper way to exit a JDialog? TIA.
 
Dennis Putnam
Ranch Hand
Posts: 377
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How did you implement that?
 
Rob Camick
Ranch Hand
Posts: 2787
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You use dialog.dispose().

If there are no active windows or Threads running then the JVM will close automatically.

Post a SSCCE that demonstrates the problem.
 
Dennis Putnam
Ranch Hand
Posts: 377
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob Camick wrote:You use dialog.dispose().

If there are no active windows or Threads running then the JVM will close automatically.

Post a SSCCE that demonstrates the problem.

That's part of the problem. I cannot reproduce it with a simple SSCCE. It only seems to happen while part of my full application. I thought just doing a 'dispose' was insufficient. Since you seem to indicate that should not be the case, I need to look for some problem that does not allow it to exit after a 'dispose'. FWIW, here is the troublesome class:
 
Rob Camick
Ranch Hand
Posts: 2787
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It only seems to happen while part of my full application.


If your full application is still running, then disposing a dialog of the application will not close the entire application.

Posting that code does not give us the context of how that dialog is used within your application.

It will only shut down if all the dialogs and main frame of the application have been disposed and there are no Threads running.

Read the API for the dispose() method of JFrame and follow the link on "AWT Threading Issues" to better understand the process.
 
Dennis Putnam
Ranch Hand
Posts: 377
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It comes from the MenuBar (line 55):
 
Dennis Putnam
Ranch Hand
Posts: 377
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm still unable to figure out why the JDialog process will not terminate. After some research I found some nebulous references to setting a parent. I didn't understand the reference but does the dispose need to be executed in the parent JFrame rather than the JDialog itself?
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!