Friday, 23 August 2013

How to force styledText to break line in SWT

How to force styledText to break line in SWT

I'm trying to force the styledText breake the line but the effects are
hopeless. Instead, it extends size of my shell to width of biggest line.
I am trying to achieve that by creating class which extends shell
My constructor
super(SWT.ON_TOP | SWT.NO_TRIM | SWT.NO_FOCUS | SWT.NO_SCROLL);
FillLayout layout = new FillLayout();
layout.marginHeight = 1;
layout.marginWidth = 1;
setLayout(layout);
mForm = new ManagedForm(this);
FormToolkit toolkit = mForm.getToolkit();
body = mForm.getForm().getBody();
FillLayout layout2 = new FillLayout();
layout2.spacing = 2;
body.setLayout(layout2);
body = toolkit.createComposite(body, SWT.BORDER );
And when i want insert and show text. I am do this like that\ String text =
body = mForm.getToolkit().createComposite(parent, SWT.BORDER);
GridLayout l = new GridLayout();
l.marginHeight = 0;
l.marginWidth = 1;
body.setLayout(l);
StyledText bodyText = createDisabledText(body, text);
mForm.getForm().getContent().pack();
mForm.getForm().reflow(true);
pack();
setVisible(true);
and my create disabledText:
private StyledText createDisabledText(Composite parent, String value)
{
StyledText t = new StyledText(parent, SWT.SHADOW_NONE);
t.setText(value);
t.setEditable(false);
t.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
return t;
}
All is in class which extends shell. What i am doing wrong or is there
method like set maxSize?

No comments:

Post a Comment