Home
Categories
Dictionary
Download
Project Details
Changes Log
FAQ
License

Swing utility classes



There are three Swing utility classes helping to use the API in a Swing environment:

Dependencies

You just need to have the scriptHelperSwing.jar file in your Classpath.

Showing logs

Logs are handled by the DefaultSwingScriptLogger and the DefaultSwingScriptLoggerArea classes.

To show the logs in a Swing window, just use the following:
      ScriptWrapper<Script> wrapper = new GroovyScriptWrapper() {
      }
      ...
      DefaultSwingScriptLogger(); logger = new DefaultSwingScriptLogger();
      wrapper.setScriptLogger(logger);

Showing exceptions

Exceptions StackTrace are handled by the SwingExceptionListener class.

To show the exceptions in a Swing window, just use the following:
      ScriptWrapper<Script> wrapper = new GroovyScriptWrapper() {
      }
      ...
      SwingExceptionListener listener = new SwingExceptionListener();
      wrapper.addExceptionListener(listener);
Then the first exception encountered during the compilation or execution of the script will popup the following window, for example:
swingError
StackTraces are also shown and clicking on a StackTrace element allows to go to the associated line in the script. For example:
swingErrorStackTrace

Behavior of the error window

By default the error window will not reappear in the script session but the next error message will only be shown in the logger. However it is possible to configure the SwingExceptionListener so that all exceptions will trigger the apparition of the error window by:
      listener.resetWrapperOnDispose(true);
In this case, the window will show a "dismiss" option for quitting the widnwo to allow to reset to the default behavior:
swingErrorDismiss

See also


Categories: swing

Copyright 2019-2020 Herve Girod. All Rights Reserved. Documentation and source under the BSD licence