Java 如何在SWT中将屏幕拆分为3个部分?
我是SWT和java的新手 我真的需要帮助 我需要构建一个Eclipse插件,当您按下按钮时,它会打开一个对话框 该对话框应该如下所示Java 如何在SWT中将屏幕拆分为3个部分?,java,swt,jface,Java,Swt,Jface,我是SWT和java的新手 我真的需要帮助 我需要构建一个Eclipse插件,当您按下按钮时,它会打开一个对话框 该对话框应该如下所示 label 1 textBox1 label 2 textBox 2 label 3 textBox13 label 4 textBox 4 could be alot of them -> should be with scroller
label 1 textBox1 label 2 textBox 2
label 3 textBox13 label 4 textBox 4
could be alot of them -> should be with scroller
---------------------------------------------------
output ( should be textbox)
-----------------------------------------------------
messages ( should be textbox)
可能有很多标签和文本框,我如何将它们添加到可以容纳很多标签和文本框的控件中?(应使用滚动条)
如何在SWT或fjace中将屏幕拆分为3个部分?我如何控制大小,例如,第一部分(标签文本框)为60%,输出为30%,消息为10%
也许你能帮我举个例子吗?这要求的代码太多了-你应该向我们展示你的尝试 一些提示: 使用
org.eclipse.jface.dialog.dialog
对于该对话框,您还可以使用org.eclipse.jface.dialog.titlearealog
,该对话框有一个错误消息区域
要按百分比分割区域,请使用org.eclipse.swt.custom.SashForm
要在一行中获取多个项目,请使用指定列数的org.eclipse.swt.layout.GridLayout
要获得滚动区域,请使用org.eclipse.swt.custom.ScrolledComposite
比如:
@Override
protected Control createDialogArea(final Composite parent)
{
Composite body = (Composite)super.createDialogArea(parent);
// Vertical sash
SashForm sashForm = new SashForm(body, SWT.VERTICAL);
sashForm.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
// First part, scrollable
ScrolledComposite scrolledComp = new ScrolledComposite(sashForm, SWT.V_SCROLL);
Composite comp1 = new Composite(scrolledComp, SWT.NONE);
comp1.setLayout(new GridLayout());
// TODO: add controls to comp1
// Set scroll size - may need to adjust this
Point size = comp1.computeSize(SWT.DEFAULT, SWT.DEFAULT);
scrolledComp.setMinHeight(size.y);
scrolledComp.setMinWidth(size.x);
scrolledComp.setExpandVertical(true);
scrolledComp.setExpandHorizontal(true);
scrolledComp.setContent(comp1);
// Second part
Composite comp2 = new Composite(sashForm, SWT.NONE);
comp2.setLayout(new GridLayout());
// TODO: add controls to comp2
// Third part
Composite comp3 = new Composite(sashForm, SWT.NONE);
comp3.setLayout(new GridLayout());
// TODO: add controls to comp3
// Set the sash weighting (must be after controls are created)
sashForm.setWeights(new int [] {60, 30, 10});
return body;
}
我的意思是,拆分为3个部分,并在一行中添加多个项目,与scrollerI一起使用我是SWT中的新手,所以我希望小帮助简短示例继续