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

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

Introduction

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

Prototype

public void setTabStops(int[] tabs) 

Source Link

Document

Sets the receiver's tab list.

Usage

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

public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setText("Snippet 325");
    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 2 s  .  c om*/
    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.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();
}

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;/*from   w w w  .j av a2 s .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();
}