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

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

Introduction

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

Prototype

public void setBounds(int x, int y, int width, int height) 

Source Link

Document

Sets the receiver's size and location to the rectangular area specified by the arguments.

Usage

From source file:StyledTextPaint.java

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

    Shell shell = new Shell(display);
    shell.setBounds(10, 10, 250, 250);/* www  .  ja va  2  s. com*/
    final StyledText text = new StyledText(shell, SWT.NONE);
    text.setBounds(10, 10, 200, 200);
    text.addListener(SWT.Paint, new Listener() {
        public void handleEvent(Event event) {
            System.out.println("paint");

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

From source file:StyledTextCreate.java

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

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

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

    shell.open();//w w  w .j  a  v  a2 s  .  c  o  m
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            display.sleep();
        }
    }
    display.dispose();

}

From source file:TextAroundBox.java

public static void main(String[] args) {
    final Display display = new Display();
    final Color RED = display.getSystemColor(SWT.COLOR_RED);
    Shell shell = new Shell(display);
    shell.setBounds(10, 10, 250, 250);//from   w  w w . j  a va 2  s  .  c  o m
    final StyledText text = new StyledText(shell, SWT.NONE);
    text.setBounds(10, 10, 200, 200);
    text.addListener(SWT.Paint, new Listener() {
        public void handleEvent(Event event) {
            String contents = text.getText();
            int stringWidth = event.gc.stringExtent(SEARCH_STRING).x;
            int lineHeight = text.getLineHeight();
            event.gc.setForeground(RED);
            int index = contents.indexOf(SEARCH_STRING);
            while (index != -1) {
                Point topLeft = text.getLocationAtOffset(index);
                event.gc.drawRectangle(topLeft.x - 1, topLeft.y, stringWidth + 1, lineHeight - 1);
                index = contents.indexOf(SEARCH_STRING, index + 1);
            }
        }
    });
    text.setText("This demonstrates drawing a box\naround every occurrence of the word\nbox in the StyledText");
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    display.dispose();
}

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);
    shell.open();/*w  w  w  . j  a v a  2 s.c om*/
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            display.sleep();
        }
    }
    display.dispose();

}

From source file:StyledTextTabSize.java

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

    StyledText styledText = new StyledText(shell, SWT.V_SCROLL | SWT.BORDER);
    styledText.setText("12345");

    styledText.setTabs(2);/*from   w w  w.  jav  a 2 s  . c  o  m*/

    styledText.setBounds(10, 10, 100, 100);
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            display.sleep();
        }
    }
    display.dispose();

}

From source file:StyledTextPrint.java

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

    StyledText styledText = new StyledText(shell, SWT.V_SCROLL | SWT.BORDER);

    styledText.setText("12345");

    styledText.print();/*  ww w  .  ja  va 2 s  . c  o  m*/

    styledText.setBounds(10, 10, 100, 100);
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            display.sleep();
        }
    }
    display.dispose();

}

From source file:StyledTextLimit.java

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

    StyledText styledText = new StyledText(shell, SWT.V_SCROLL | SWT.BORDER);
    styledText.setText("12345");

    styledText.setTextLimit(10);/*from   w ww.  ja  va  2s. c  om*/

    styledText.setBounds(10, 10, 100, 100);
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            display.sleep();
        }
    }
    display.dispose();

}

From source file:StyledTextReadOnly.java

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

    StyledText styledText = new StyledText(shell, SWT.V_SCROLL | SWT.BORDER);
    styledText.setText("12345");

    styledText.setEditable(false);/*from  w w w.ja  va2s  .  c om*/

    styledText.setBounds(10, 10, 100, 100);
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            display.sleep();
        }
    }
    display.dispose();

}

From source file:StyledTextReplaceTextRange.java

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

    final StyledText styledText = new StyledText(shell, SWT.V_SCROLL | SWT.BORDER);
    styledText.setText("12345");

    styledText.replaceTextRange(2, 3, "A");

    styledText.setBounds(10, 10, 100, 100);
    shell.open();//from ww  w  .j  ava  2s.  c o  m
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            display.sleep();
        }
    }
    display.dispose();
}

From source file:StyledTextKeyBound.java

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

    StyledText styledText = new StyledText(shell, SWT.V_SCROLL | SWT.BORDER);
    styledText.setText("12345");

    int zAction = styledText.getKeyBinding('z');

    styledText.setBounds(10, 10, 100, 100);
    shell.open();//from  w  w  w .  j  av a2  s.  co m
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            display.sleep();
        }
    }
    display.dispose();

}