Example usage for org.eclipse.swt.custom StyledText paste

List of usage examples for org.eclipse.swt.custom StyledText paste

Introduction

In this page you can find the example usage for org.eclipse.swt.custom StyledText paste.

Prototype

public void paste() 

Source Link

Document

Replaces the selection with the text on the DND.CLIPBOARD clipboard or, if there is no selection, inserts the text at the current caret offset.

Usage

From source file:StyledTextClipboard.java

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

    StyledText text1 = new StyledText(shell, SWT.V_SCROLL | SWT.WRAP | SWT.BORDER);
    StyledText text2 = new StyledText(shell, SWT.V_SCROLL | SWT.WRAP | SWT.BORDER);

    text1.setText("1234567");

    text1.setSelectionRange(2, 4);//from  w w w  . j a  va2s.c  o  m

    text1.cut();
    text2.paste();

    text1.setBounds(10, 10, 100, 100);

    text2.setBounds(10, 300, 100, 100);

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

}