[英]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.