JMEDesktop Disposal

Okay, you know how when you create a JFrame you need to dispose() it before the AWT Thread will end and the VM can terminate normally?  Well, I think we need some convenience method in JMEDesktop to execute that since the JFrame isn't visible programmatically.  As a temporary work-around I'm using:


It would be a lot easier if I could just say:






What!?! You want to dispose the great JMEDesktop?!? I can't sanction that :stuck_out_tongue:

Ok, ok, some apps might want to exit - method added :slight_smile:

Is everything written by the Great Irrisor "great"? :-p

In this case I would have to concur, JMEDesktop is phenominal even when I can't dispose of it.



Can I also request that second method be added as well so on termination of the application any JMEDesktops created can dispose of themselves without explicitly calling each one?


I don't think that a static dispose method would be a good idea. JMEDesktop would have to maintain a static list of all created desktops. I think it's on the application to do this if really necessary.

What if you were to maintain a static HashSet of WeakReferences to the JMEDesktops and then you aren't inhibiting them from being cleared, but if they aren't cleared upon JMEDesktop.dispose() the ones that maintained a reference can be cycled through and dispose called on them?  The problem I'm trying to handle is I'm creating a extension of AbstractGame that does not use System.exit(0) at the end and in a situation where an implementing game created a JMEDesktop and for whatever reason doesn't close it upon termination I want to be able to dispose of that.  If it's added to JMEDesktop then I'm not having to do some work-around wrapper class for it and I would think it would be beneficial to be able to add to the end of SimpleGame JMEDesktop.disposeAll() to drop the AWT thread.


Simply overwrite the cleanup method and do for( mydesktops ) desktop.dispose() !?! That'd be much better. I'd consider the JMEDesktop.disposeAll to be a workaround for applications that can't handle their desktops :stuck_out_tongue: