Override Default Action for SWT Text Field

Normally the default button will be triggered when the enter key is pressed in a text field and the text field will loose the focus.

This can be change/overridden:

    Text text = new Text(shell, SWT.SINGLE | SWT.BORDER);
    text.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    text.setText("Here is some text");
    text.addSelectionListener(new SelectionAdapter() {
      public void widgetDefaultSelected(SelectionEvent e) {
            .println("Text default selected (overrides default button)");
    text.addTraverseListener(new TraverseListener() {
      public void keyTraversed(TraverseEvent e) {
        if (e.detail == SWT.TRAVERSE_RETURN) {
          e.doit = false;
          e.detail = SWT.TRAVERSE_NONE;