Google Web Toolkit

Preferences - Google > Web Toolkit > Designer > Event Handlers

This page is used to control various Google > Web Toolkit > Designer > Event Handlers options.

Event code generation

This preference determines how event handlers are generated. The first option, Create anonymous class, generates an anonymous adapter class located inline with the widget definition. For example:

       Button button = new Button(shell, SWT.NONE);
       button.addSelectionListener(new SelectionAdapter() {
              public void widgetSelected(SelectionEvent e) {
              }
       });

The second option, Create inner class, generates an adapter class as an inner class. Options are provided to add the inner class at the beginning or end of the class as well as specify the pattern used to name the inner class:

                private class ButtonSelectionListener extends SelectionAdapter {
              public void widgetSelected(SelectionEvent e) {
              }
       }
       ...
       Button button = new Button(shell, SWT.NONE);
       button.addSelectionListener(new ButtonSelectionListener());

The pattern can include the template variables (names enclosed between "${" and "}") shown below. Capitalizing the name of any variable will cause the value of the variable to be capitalized before it is inserted into the resulting text.

  • component_name - the name of the component to which the handler is being attached
  • component_class_name - the name of the class of the component to which the handler is being attached
  • listener_name - the name of the event being handled
  • listener_className - the name of the event listener

The third option, Implement listener interface in parent class, adds the the listener interface to the parent class and adds the appropriate methods to the class definition. For example:

                public class MyClass implements SelectionListener {
       ...
       Button button = new Button(shell, SWT.NONE);
       button.addSelectionListener(this);
       ...
       public void widgetSelected(SelectionEvent e) {
       }
       public void widgetDefaultSelected(SelectionEvent e) {
       }

Create stub event handler methods named

This preference determines whether the text field below it is enabled.� Now whenever an event handler is added, a method stub is created with the name given in the text field.� A line of code is also added to the event handler which calls the newly created method.

    Delete stub event handler methods on component delete

    This preference determines whether handler methods associated with a component are deleted when the component is deleted.

    Declare parameters in event handlers as 'final'

    This preference determines whether 'final' is added to the parameters in event handlers.

    Show icon decorator for components with events

    This preference controls whether components with event handlers are shown with an icon decorator.

    Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 3.0 License.

    Authentication required

    You need to be signed in with Google+ to do that.

    Signing you in...

    Google Developers needs your permission to do that.