Multi-Line Button text in SWT/WindowBuilder?

Zoot picture Zoot · Dec 28, 2010 · Viewed 7.4k times · Source

Is there any way to force the SWT button text to span two lines, either manually in the SWT code or using the WindowBuilder GUI? I have this: alt text

I want something like this (digitally altered image to achieve this): alt text

Is it possible? How?

Answer

Monikka picture Monikka · Feb 21, 2014

I was able to get the multi-line button text work, by adding SWT.WRAP as a style for the button and by having '\n' inserted in the text to be set as the button label.

....
Button check = new Button(composite, SWT.WRAP | SWT.PUSH );
check.setText("Multi\n Line\n Button \n Text");
....

Even though the button.setText(..) java doc says that the button label must not contain new line chars, it works when SWT.WRAP is added as a style('\n' were ignored when SWT.WRAP was not set).

Just thought this could be useful.

enter image description here