Home
Categories
Dictionary
Download
Project Details
Changes Log
FAQ
License

Swing Script helper



The DefaultSwingScriptHelper class is a swing implementation of the ScriptHelper which has additional methods.

DefaultSwingScriptHelper API

The DefaultSwingScriptHelper class has several additional methods.

Asking for a property

The following methods will show a popup window asking for a property. Upon closing the popup window, the method will return the result of the user property edition or selection:
If the user cancels the dialog without entering a value, the result will be null.

Asking for a file or a directory

The following methods will simply show a dialog to select a file or a directory:
The DefaultSwingScriptHelper.getImports() return the set of additional imports to use with these additional methods[1]
It does not include the File import
.

Examples

Setting one value

The following code shows a dialog window allowing to set an int:

   public int execute() {
      Integer value = helper.askForIntProperty("Value", 0, 100, 1);
      if (value != null) {
        return value;
      } else {
        return 0;
      }
   }

Setting more than one value

The following code shows a dialog window allowing to set an int and a boolean:

   public int execute() {
      PropertySetter setter = helper.getPropertySetter("Set Values");
      setter.addProperty("int", "Int Value", PropertyTypes.TYPE_INT, 0, 100, 1);
      setter.addProperty("bool", "Boolean Value", PropertyTypes.TYPE_BOOLEAN);
      setter.askForProperties();
      int i = setter.getIntProperty("int", 0);
      boolean b = setter.getBooleanroperty("bool");
      if (b) {
        return i;
      } else {
        return 0;
      }
   }

Notes

  1. ^ It does not include the File import

See also


Categories: api | swing

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