2017-07-21 4 views
0

Ich versuche, das Widget zu machen: enter image description hereWie kann ich verschiedene Elemente in zwei Verbundwerkstoffen ausrichten?

Dafür schaffe ich ein Verbund für die Gruppe (mit 1-Säule) und ein Verbund mit 2 Säulen (für das Label und Text) für ID und Passwort

Und dann, ich erstelle eine Zusammensetzung für die 3 Felder (Kontrollkästchen, Label und Text) mit 3 Spalten

Aber die letzte Zeile ist nicht mit der ID und Passwort ausgerichtet, weil ich vertikal ausrichten möchte die "Retry versucht "mit den Textfeldern:

enter image description here

Mein Code ist:

Composite sqlComposite = new Composite(parent, SWT.NONE); 
sqlComposite.setLayout(new GridLayout(1, false)); 
sqlComposite .setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); 

Group sqlGoup = new Group(sqlComposite, SWT.NONE); 
group.setLayout(new GridLayout(1, false)); 
group.setText("sql connection");  

Composite sql2Composite = new Composite(sqlGoup, SWT.NONE); 
sql2Composite.setLayout(new GridLayout(2, false)); 
sql2Composite .setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); 


Label label = new Label(sql2Composite, SWT.NONE); 
label.setText("Id"); 
Text textBoxID = new Text(sql2Composite, SWT.BORDER); 
textBoxID.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); 


Label label = new Label(sql2Composite, SWT.NONE); 
label.setText("Password"); 
Text textBoxPass = new Text(sql2Composite, SWT.BORDER); 
textBoxPass.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); 


Composite sqlButtonsComposite = new Composite(sqlGoup, SWT.NONE); 
sqlButtonsComposite.setLayout(new GridLayout(3, false)); 
sqlButtonsComposite.setLayoutData(new GridData(SWT.NONE, SWT.NONE, false, false)); 

_encryptCheckButton = new Button(sqlButtonsComposite, SWT.CHECK); 
_encryptCheckButton.setText("Encrypt"); 
_encryptCheckButton.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, true, false)); 

Label labelSpinner = new Label(sqlButtonsComposite , SWT.NONE); 
labelSpinner.setText("RetryAttempts"); 
_retryAttemptsSpinner = new Spinner(sqlButtonsComposite, SWT.BORDER); 
_retryAttemptsSpinner.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, true, false)); 
_retryAttemptsSpinner.setMinimum(MIN_DELTA_SPINNER); 
_retryAttemptsSpinner.setMaximum(MAX_DELTA_SPINNER); 
_retryAttemptsSpinner.setSelection(DEFAULT_SPINNER_NUMBER); 
_retryAttemptsSpinner.setIncrement(INCREMENT_SPINNER_NUMBER); 

Also meine Frage ist: wie kann ich die ID, Passwort und das Kontrollkästchen namens Encrypt ausrichten?

Dank

Antwort

4

Sie nicht leicht Ausrichtung mit zwei Composites erhalten können. So verwenden Sie eine Composite-mit 3 Spalten und machen die Textsteuer umspannen zwei Spalten:

Composite sql2Composite = new Composite(sqlGoup, SWT.NONE); 
// 3 columns 
sql2Composite.setLayout(new GridLayout(3, false)); 
sql2Composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); 

Label label = new Label(sql2Composite, SWT.NONE); 
label.setText("Id"); 

Text textBoxID = new Text(sql2Composite, SWT.BORDER); 
// Span 2 columns 
textBoxID.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1)); 

label = new Label(sql2Composite, SWT.NONE); 
label.setText("Password"); 

Text textBoxPass = new Text(sql2Composite, SWT.BORDER); 
// Span 2 columns 
textBoxPass.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1)); 

// No second composite 

_encryptCheckButton = new Button(sql2Composite, SWT.CHECK); 
_encryptCheckButton.setText("Encrypt"); 
// Don't grab extra space 
_encryptCheckButton.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false)); 

Label labelSpinner = new Label(sql2Composite , SWT.NONE); 
labelSpinner.setText("RetryAttempts"); 
_retryAttemptsSpinner = new Spinner(sql2Composite, SWT.BORDER); 
// Don't grab extra space 
_retryAttemptsSpinner.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false)); 

Ich habe hinzugefügt Kommentare oben, wo die Dinge benötigen für Ihre Hilfe geändert

+0

es funktioniert, vielen Dank werden !! Ich verstehe mein Problem jetzt – Bob

Verwandte Themen