Java Code Examples for org.eclipse.swt.widgets.Text#computeTrim()

The following examples show how to use org.eclipse.swt.widgets.Text#computeTrim() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
@Override
protected Text newText(final Composite textContainer) {
    final Text text = new Text(textContainer, SWT.MULTI | SWT.V_SCROLL | SWT.WRAP);
    text.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
    final Listener scrollBarListener = event -> {
        final Text t = (Text) event.widget;
        final Rectangle r1 = t.getClientArea();
        final Rectangle r2 = t.computeTrim(r1.x, r1.y, r1.width, r1.height);
        final Point p = t.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
        t.getVerticalBar().setVisible(r2.height <= p.y);
        if (event.type == SWT.Modify) {
            t.getParent().layout(true);
            t.showSelection();
        }
    };
    text.addListener(SWT.Resize, scrollBarListener);
    text.addListener(SWT.Modify, scrollBarListener);
    return text;
}