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

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

Introduction

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

Prototype

public void redraw() 

Source Link

Document

Causes the entire bounds of the receiver to be marked as needing to be redrawn.

Usage

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

    final MultiLineCommentListener lineStyleListener = new MultiLineCommentListener();
    styledText.addLineStyleListener(lineStyleListener);

    styledText.addExtendedModifyListener(new ExtendedModifyListener() {
        public void modifyText(ExtendedModifyEvent event) {
            // Recalculate the comments
            lineStyleListener.refreshMultilineComments(styledText.getText());
            // Redraw the text
            styledText.redraw();
        }//w  ww  . jav a2 s . c  o  m
    });

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

From source file:MultiLineComment.java

/**
 * Creates the main window contents//from   w ww  .  j a  v  a  2 s .  c  o  m
 * 
 * @param shell the main window
 */
private void createContents(Shell shell) {
    shell.setLayout(new FillLayout());
    final StyledText styledText = new StyledText(shell, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);

    // Add the line style listener
    final MultiLineCommentListener lineStyleListener = new MultiLineCommentListener();
    styledText.addLineStyleListener(lineStyleListener);

    // Add the modification listener
    styledText.addExtendedModifyListener(new ExtendedModifyListener() {
        public void modifyText(ExtendedModifyEvent event) {
            // Recalculate the comments
            lineStyleListener.refreshMultilineComments(styledText.getText());

            // Redraw the text
            styledText.redraw();
        }
    });
}