gpt4 book ai didi

java - SWT中如何将组合体划分为不同的空间

转载 作者:行者123 更新时间:2023-11-30 03:48:35 24 4
gpt4 key购买 nike

我在 SWT 中创建一个日志查看器,遇到了一个需要显示 mainText 和DetailedText 的问题。我希望 mainText 仅具有 25% 或可用空间,detailText 应具有 75% 可用空间。所以我继续尝试学习 swt 中的布局管理器 mention here 。看起来 SWT 没有任何适合我的布局管理器。我目前正在使用 FillLayout ,它只是将复合 Material 分成相等的空间。有什么办法可以根据我的方便来划分空间吗?

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

这就是消息的显示方式

enter image description here

这就是我想要的

enter image description here

有人可以帮助我并引导我走向正确的方向吗?提前致谢。

最佳答案

我衷心感谢 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")
}
}

关于java - SWT中如何将组合体划分为不同的空间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24959861/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com