简体   繁体   English

如何在SWT中将合成物划分为不同的空间

[英]How to divide the composite into different spaces in SWT

I am create a log viewer in SWT and I ran across a problem where I need to display the mainText and detailedText. 我在SWT中创建了一个日志查看器,遇到一个需要显示mainText和detailText的问题。 I wants the mainText to have only 25% or available space and detailText should have 75% available space. 我希望mainText仅具有25%的可用空间,而detailText应该具有75%的可用空间。 So I went ahead and try to learn layout manager in swt mention here . 因此,我继续尝试在这里提到的 swt学习布局管理器。 Looks like SWT does not have any respective layout manger for me. 看起来SWT对我来说没有任何布局管理器。 I am currently using FillLayout which is simply diving the composite into equal space. 我目前正在使用FillLayout ,它只是简单地将复合材料分成相等的空间。 Is there any way I can divide the space according to my convenience. 有什么办法可以根据我的方便划分空间。

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")
 }
}

This is how message is appearing 这是消息出现的方式

在此处输入图片说明

This is how I want 这就是我想要的

在此处输入图片说明

Could someone please help me and guide me in the right direction. 有人可以帮助我,并指导我正确的方向。 Thanks in advance. 提前致谢。

I would sincerely like to thanks greg-449. 我衷心感谢greg-449。 His comment made it possible. 他的评论使之成为可能。 He suggested me to use org.eclipse.swt.custom.SashForm and it works perfectly. 他建议我使用org.eclipse.swt.custom.SashForm ,它运行完美。 Thanks SO again. 再次感谢。 Here is my updated code. 这是我更新的代码。

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM