Pahlevi Fikri Auliya
Pahlevi Fikri Auliya

Reputation: 4527

How to enable/disable SWT Text WRAP in runtime

I have a SWT button (with SWT.CHECK flag) and SWT Text. Upon pressed, SWT button should enable/disable the wrapping of the SWT text.

I am aware that text wrapping capability is specified in the constructor as follow:

new Text(parent, SWT.WRAP)

But I couldn't find a method such as setWrap(false) to programmatically enable/disable it in runtime.

Is there a way to do this in SWT? Or the only solution is to dispose the old text, and create a new one with different flag?

Upvotes: 3

Views: 320

Answers (1)

greg-449
greg-449

Reputation: 111142

In general SWT styles can't be changed and this is the case for the Wrap style of the Text control.

The StyledText control does have a setWordWrap(boolean) method, you should be able to use that.

Upvotes: 3

Related Questions