Parameters

Parameters allow you to customise the execution of a command on a case by case basis. They can be specified a number of ways, but are always cleared after every execution. Parameters can be specified in the following manner:

  • By calling putParameter(String key, Object value) prior to execution.
  • By calling putParameters(Map parameters) prior to execution.
  • By passing the parameters to execute(Map parameters).

Default Parameters

Commands executed as a result of a a button or menu click predefine a number of parameters for you, these are as follows:

  • ActionCommand.PARAMETER_ACTION_EVENT - The ActionEvent that triggered the command. This is also available via the getActionEvent() convenience method.
  • ActionCommand.PARAMETER_MODIFIERS - The modifiers that were active when the button was activated. This is also available via the getModifiers() convenience method.
  • ActionCommand.PARAMETER_INVOKER - The component that invoked the command. This is also available via the getInvoker() convenience method.
  • ActionCommand.PARAMETER_INVOKER_WINDOW - The parent window of the invoker. This parameter is automatically calculated from the invoker and is available via the getInvokerWindow() convenience method.

Creating Parameterised Buttons

ActionCommands also allow you to create buttons that will always invoke a command with a particular set of parameters.

   ActionCommand command = ...'

   HashMap parameters = new HashMap();
   parameters.put("parameter-one", "value-one");
   parameters.put("parameter-two", "value-two");

   AbstractButton button = command.createButton(parameters);