Event handling

The XML resource and a Java class is joint by the parse methods, the XML file is given as path or input stream, and the events are handled by the thinlet instance, or a handler object as follows:

public Object parse(String path) throws IOException
public Object parse(String path, Object handler) throws IOException
public Object parse(InputStream inputstream) throws IOException
public Object parse(InputStream inputstream, Object handler) throws IOException

Parameters
The attribute value for an event in the XML file must be a public method of the handler Java object (the return type of the method doesn't count). The event description may contain parameters (in brackets, separated by comma or whitespace characters) as follows:

thinlet
It is beneficial, if the handler object wasn't your thinlet instance. The parameter type is thinlet.Thinlet, but you can cast it (e.g. (MyThinlet) thinlet).

this
The source widget (the object on which the event occurred), its type is Object.

widget name
The widget (in the same XML file) identified by the given name, its type is Object.

<button action="one" />
<label name="label1" text="..." visible="false" />
<button action="two(thinlet, this, label1)" />

public void one() {}
public void two(Thinlet thinlet, Object button, Object label) {}

item
The component part on which the event occurred, valid for list item, tree node, table row, combobox choice, and tabbedpane tab. Its type is Object, it is null, if the event wasn't associated with component item.

this/name/item.attribute
The event parameter may contain a component's or item's attribute value, defined by the this, widget name, or item string, dot, and the attribute key. The parameter type is String for string and choice attributes, boolean for boolean types, int for integers, and Image for icons. If the item was null, the String or Image parameter is null, the boolean or int parameter is the default value for those items.

<button action="three(this.text, this.icon, label1.visible, label1.colspan)" />
<list action="four(item, item.text, item.icon)">
  <item text="File" icon="file.gif" />
</list>

public void three(String buttontext, Image buttonicon, boolean labelvisible, int labelcols) {}
public void four(Object item, String itemtext, Image itemicon) {}

constant string
You can use constant number or string for the event handler method. Constant string values begin and end with apostrophe character.

constant number
Long numbers end with 'L' character (it ignors case), floats width 'F', doubles have to include a dot character, otherwise it is expected as integer.

<button text="Button" mnemonic="0" action="five('string', 12, 1234567890L, 12.34, 45.6F)" />

public void five(String s, int i, long l, double d, float f) {}

Exceptions
Your methods may throw exceptions (and even errors), by default the exception handler prints the stack trace to the console, but you can customize it (e.g. show a warning dialog) by overwriting the following method:

protected void handleException(Throwable throwable)