SWT.CR : SWT « org.eclipse.swt « Java by API






SWT.CR

import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.TreeEditor;
import org.eclipse.swt.events.FocusAdapter;
import org.eclipse.swt.events.FocusEvent;
import org.eclipse.swt.events.KeyAdapter;
import org.eclipse.swt.events.KeyEvent;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.widgets.Tree;
import org.eclipse.swt.widgets.TreeItem;

public class MainClass {

  public static void main(String[] a) {
    
    final Display d = new Display();
    final Shell shell = new Shell(d);

    shell.setSize(250, 200);
    
    
    shell.setLayout(new FillLayout());
    Text text = new Text(shell, SWT.BORDER);
    
    text.addKeyListener(new KeyAdapter() {
      public void keyPressed(KeyEvent event) {
        switch (event.keyCode) {
        case SWT.CR:
          System.out.println(SWT.CR);
        case SWT.ESC:
          System.out.println(SWT.ESC);
          break;
        }
      }
    });

    
    shell.open();
    while (!shell.isDisposed()) {
      if (!d.readAndDispatch())
        d.sleep();
    }
    d.dispose();
  }
}

           
       








Related examples in the same category

1.SWT.ARROW | SWT.LEFT
2.SWT.ARROW | SWT.LEFT | SWT.BORDER
3.SWT.ARROW | SWT.LEFT | SWT.FLAT
4.SWT.CHECK | SWT.BORDER
5.SWT.CHECK | SWT.FLAT
6.SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL
7.SWT.ESC
8.SWT.NO
9.SWT.RADIO
10.SWT.RADIO | SWT.BORDER
11.SWT.SHADOW_ETCHED_IN
12.SWT.TOGGLE | SWT.BORDER
13.SWT.TOGGLE | SWT.FLAT
14.SWT.YES