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

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

Introduction

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

Prototype

public void setWordWrap(boolean wrap) 

Source Link

Document

Sets whether the widget wraps lines.

Usage

From source file:StyledTextWordWrap.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.BORDER);

    text1.setWordWrap(!text1.getWordWrap());

    text1.setBounds(10, 10, 100, 100);// w ww.j  a v a 2  s .co m
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            display.sleep();
        }
    }
    display.dispose();

}

From source file:org.eclipse.swt.snippets.Snippet374.java

public static void main(String[] args) throws Exception {
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setText("Snippet 374");
    shell.setLayout(new FillLayout());
    shell.setText("Customize line vertical indent");

    StyledText text = new StyledText(shell, SWT.BORDER | SWT.V_SCROLL);
    text.setWordWrap(true);
    text.setText("word1 word2 word3 word4");
    text.setLineVerticalIndent(0, 20);/*from   ww w  . j  av  a2s  .c  o m*/

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

From source file:MainClass.java

protected Control createContents(Composite parent) {
    TextViewer viewer = new TextViewer(parent, SWT.V_SCROLL);
    final StyledText styledText = viewer.getTextWidget();
    styledText.setWordWrap(true);
    styledText.addKeyListener(new KeyAdapter() {
        public void keyReleased(KeyEvent event) {
            if (event.keyCode == 'p' && (event.stateMask & SWT.CTRL) != 0) {
                styledText.print();/*from   w  ww .j  av a 2 s.com*/
            }
        }
    });
    viewer.setDocument(new Document());
    return styledText;
}