Benim durumumda SashForm
iki çocuğum var, ama soru tüm Composite
s için geçerlidir.Bir SWT Kompozisyonunun çocuklarının sırasını değiştirme
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);
}
}
Bu yöntemlerin hangi sırayla çağrılacağını önceden bilmiyorum. child1
'un sola ve child2
sağ tarafa yerleştirildiğinden nasıl emin olabilirim? Alternatif olarak,'un oluşturulduktan sonra düzenlerini değiştirmek için bir yol var mı?
anda benim en iyi fikir böyle tutucuları koymak için şudur: child1 oluşturduğunuzda alt2 önceden başlatılmış olmadığını kontrol
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);
}
}
yapar. Sadece “moveAbove” in varlığını özledim çünkü “Composite” yöntemlerinden biriydim. –
Bu bilgi için teşekkürler :) Dikkat etmeniz gereken en iyi şey, boşluğa taşımak için null kullanabilmenizdir. –