我试图迫使StyledText
破坏线,但效果无望。相反,它将我的shell的大小扩展到最大行的宽度。
我试图通过创建扩展shell
的类来实现这一目标我的构造函数
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 );
当我想要插入和显示文字时。我是这样做的
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);
和我的创建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;
}
所有都是在扩展shell的类中。 我做错了什么或者有像set maxSize这样的方法吗?
答案 0 :(得分:0)
在createDisabledText
方法中,尝试将SWT.WRAP
样式传递给StyledText
构造函数。
StyledText t = new StyledText(parent, SWT.SHADOW_NONE | SWT.WRAP);