I am create a log viewer in SWT and I ran across a problem where I need to display the mainText and detailedText. I wants the mainText to have only 25% or available space and detailText should have 75% available space. So I went ahead and try to learn layout manager in swt mention here . Looks like SWT does not have any respective layout manger for me. I am currently using FillLayout
which is simply diving the composite into equal space. 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. His comment made it possible. He suggested me to use org.eclipse.swt.custom.SashForm
and it works perfectly. 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")
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.