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?

有帮助吗?

解决方案

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top