The functionality provided by GUIKit has been superseded by the interface construction and controls functions native to the built-in Wolfram Language.

GUI Life Cycles

Normally a live GUIObject instance will shut down and dispose of itself through the normal user action of closing a window or other interface widget that performs the equivalent user interface closure. Sometimes, however, it is convenient to programmatically close a live modeless interface. You can use CloseGUIObject on an active GUIObject instance to initiate a close action.

Note that CloseGUIObject only initiates a close request on the active interface and will not necessarily force the removal of all interface resources like ReleaseGUIObject if an initial GUIRun has requested the interface live on past its closing by using the option ReleaseMethod->Manual. If you want to ensure the original life cycle intent of a GUIRun call, it is recommended that you use CloseGUIObject instead of ReleaseGUIObject, since this will still close and possibly remove all resources associated with an interface if ReleaseMethod->Automatic was used or also allow the interface to live on if ReleaseMethod->Manual was used.

Here you create a live user interface object by loading a calculator example.

You can verify this user interface is active even if not displayed using GUIObjectQ.

Instead of closing the active window with the mouse, you programmatically request the window close using CloseGUIObject.

You now see that GUIObjectQ correctly reports this user interface, and its runtime representation as a GUIObject is no longer valid because GUIRun was initiated with the default Automatic release method.

Here you request instead that the definition should still stay active after it is closed using the ReleaseMethod option.

Instead of closing the active window with the mouse, you programmatically request the window close using CloseGUIObject.

Here you see that GUIObjectQ correctly reports that this definition is still active because of the initial Manual release method.

You can force complete termination of the interface using ReleaseGUIObject.

If you decide that you want to dispose of an active modeless interface either before or after it is already displayed, you can use ReleaseGUIObject to force shutdown and remove all resources allocated to the running user interface.

Here you gain access to the GUIObject associated with an interface created in a modeless session.

Once you call ReleaseGUIObject, the interface is closed just as if the user closed the user interface through normal interaction.

The resources and the JavaObject associated with the user interface are now cleared.

You can also use the GUIObjectQ function to determine a live GUIObject reference from one that is now shut down.

However, it is probably more appropriate to use CloseGUIObject to only initiate the close action on the active interface. The reason for this is that GUIRun supports the option ReleaseMethod->Manual to allow you to reuse a live definition even after it is closed and reopened.

A common useful technique that takes advantage of the ReleaseMethod->Manual option of GUIRun is to define and use a single copy of a definition throughout a single kernel session, automatically handling the initial creation, as well as redisplaying it if it has happened to be closed manually by a user. The following wrapper function for requesting a specific interface definition supports all these concepts nicely, where "Wolfram/Example/PrimeFinder" represents the path to the definition you are interested in.