[英]How to divide the composite into different spaces in SWT
我在SWT中创建了一个日志查看器,遇到一个需要显示mainText和detailText的问题。 我希望mainText仅具有25%的可用空间,而detailText应该具有75%的可用空间。 因此,我继续尝试在这里提到的 swt学习布局管理器。 看起来SWT对我来说没有任何布局管理器。 我目前正在使用FillLayout
,它只是简单地将复合材料分成相等的空间。 有什么办法可以根据我的方便划分空间。
public class LogViewer{
Text mainText;
Text detailText;
public void initialize(Composite parent){
parent.setLayout(new FillLayout(SWT.VERTICAL));
mainText = new Text( parent, SWT.WRAP | SWT.MULTI | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL );
detailText = new Text( parent, SWT.WRAP | SWT.MULTI | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL );
mainText.setVisible( true );
detailText.setVisible( true );
mainText.setText("This is the error message");
detailText.setText("This text is mulitline error text message")
}
}
这是消息出现的方式
这就是我想要的
有人可以帮助我,并指导我正确的方向。 提前致谢。
我衷心感谢greg-449。 他的评论使之成为可能。 他建议我使用org.eclipse.swt.custom.SashForm
,它运行完美。 再次感谢。 这是我更新的代码。
public class LogViewer{
Text mainText;
Text detailText;
public void initialize(Composite parent){
parent.setLayout(new FillLayout(SWT.VERTICAL));
SashForm sashForm =new SashForm(parent, SWT.VERTICAL);
mainText = new Text( sashForm , SWT.WRAP | SWT.MULTI | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL );
detailText = new Text( sashForm , SWT.WRAP | SWT.MULTI | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL );
mainText.setVisible( true );
detailText.setVisible( true );
sashForm.setWeights(new int[]{1,3});
mainText.setText("This is the error message");
detailText.setText("This text is mulitline error text message")
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.