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

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

Introduction

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

Prototype

public void setLineTabStops(int startLine, int lineCount, int[] tabStops) 

Source Link

Document

Sets the tab stops of the specified lines.

Usage

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

public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setText("Snippet 328");
    shell.setLayout(new GridLayout());
    shell.setText("StyledText: Variable tab stops");

    Ruler ruler = new Ruler(shell, SWT.NONE);
    GridData data = new GridData();
    data.heightHint = 10;/* w  ww.ja v a 2s.co m*/
    data.horizontalAlignment = SWT.FILL;
    ruler.setLayoutData(data);
    ruler.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND));

    StyledText styledText = new StyledText(shell,
            SWT.FULL_SELECTION | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
    styledText.setText(
            "0\t1\t2\t3\t4\nDrag\tthe\ttab\tmarks\ton\ttop\tto\tchange\tthe\tposition\tof\tthe\ttab\tstops");
    styledText.setTabStops(new int[] { 30, 70, 90, 140 });
    styledText.setLineTabStops(0, 1, new int[] { 10, 60, 80 });
    styledText.setLineTabStops(1, 1, new int[] { 40, 70, 100, 150 });
    styledText.setLayoutData(new GridData(GridData.FILL_BOTH));
    ruler.setEditor(styledText);

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