11
在我的情况下,我有两个SashForm
的孩子,但该问题适用于所有Composite
s。更改SWT复合材料儿童的顺序
class MainWindow {
Sashform sashform;
Tree child1 = null;
Table child2 = null;
MainWindow(Shell shell) {
sashform = new SashForm(shell, SWT.NONE);
}
// Not called from constructor because it needs data not available at that time
void CreateFirstChild() {
...
Tree child1 = new Tree(sashform, SWT.NONE);
}
void CreateSecondChild() {
...
Table child2 = new Table(sashform, SWT.NONE);
}
}
我不知道这些方法将被调用的顺序是什么。我如何确保child1
位于左侧,child2
位于右侧?另外,有没有办法改变他们的订单作为sashform
的子女后他们创建?
目前我最好的办法是放在占位符这样的:
class MainWindow {
Sashform sashform;
private Composite placeholder1;
private Composite placeholder2;
Tree child1 = null;
Table child2 = null;
MainWindow(Shell shell) {
sashform = new SashForm(shell, SWT.NONE);
placeholder1 = new Composite(sashform, SWT.NONE);
placeholder2 = new Composite(sashform, SWT.NONE);
}
void CreateFirstChild() {
...
Tree child1 = new Tree(placeholder1, SWT.NONE);
}
void CreateSecondChild() {
...
Table child2 = new Table(placeholder2, SWT.NONE);
}
}
它的确如此。我错过了'moveAbove'的存在,因为我正在查看'Composite'的方法。 – 2010-05-06 12:23:03
感谢此信息:)要注意的一件好事是您可以使用null将其移动到顶部。 – 2015-09-29 06:50:41