JSwat must be prepared in a very particular fashion, otherwise it is quite likely that something will go wrong later on. Fortunately, this is achieved in a very simple manner. Below is a code snippet to initailize JSwat and prepare it for use.
Main.init(); Main.setUIAdapter(YourUIAdapter.class); Session session = Main.newSession();
The Main
class referenced in the code snippet above
is none other than com.bluemarsh.jswat.Main
, which is
used to start up and tear down JSwat.
initComplete()
When this method is called in your UI adapter, you should take the following actions:
Panel
s are being displayed, they must
have their refreshLater()
methods called (the same as
might be done in the refreshDisplay()
method).CommandManager
is to be used to interpret
user input, you should invoke runRCFiles()
in the
com.bluemarsh.jswat.ui.StartupRunner
class.As with initialization, terminating JSwat properly is rather important. Again, the code for properly closing JSwat is extremely simple.
// Using the Session instance returned from Main.newSession()... Main.endSession(session, false);
If the second argument to endSession()
is
true
, Main
will invoke the
exit()
method on the UI adapter associated with the
Session. The exit()
method of your UI adapter can do
whatever is sensible for the environment. Typically this means
calling System.exit()
. If, however, your UI adapter is a
plugin to another application, it would probably do nothing when this
method is invoked.