Bonsoir,

quelqu'un pour me dire comment centrer mes 3 label sur une même ligne ?
Malgré que je définisse un GridLayout de 3 colonnes, les 3 labels sont les uns sur les autres tout à gauche....

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
 
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
 
public class LayoutTest {
 
 
	public static void main(String[] args) {
		Display display = new Display();
		Shell shell = new Shell(display);
		Composite mainComposite = new Composite(shell, SWT.NONE);
		mainComposite.setSize(300,300);
 
		GridLayout mainLayout = new GridLayout();
		mainLayout.numColumns = 3;
		mainComposite.setLayout(mainLayout);
 
		Label leftArrow = new Label(mainComposite, SWT.NONE);
		leftArrow.setText("L");
		leftArrow.setSize(15, 15);
		GridData leftArrowLayoutData = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
		leftArrow.setLayoutData(leftArrowLayoutData);
 
		Label title = new Label(mainComposite, SWT.NONE);
		title.setText("Le titre");
		title.setSize(100, 15);
		title.setAlignment(SWT.CENTER);
		title.setBackground(new Color(display, 255, 255, 255));
		GridData titleLayoutData = new GridData(GridData.HORIZONTAL_ALIGN_CENTER);
		title.setLayoutData(titleLayoutData);
 
		Label rightArrow = new Label(mainComposite, SWT.NONE);
		rightArrow.setText("R");
		rightArrow.setSize(15, 15);
		GridData rightArrowLayoutData = new GridData(GridData.HORIZONTAL_ALIGN_END | GridData.GRAB_HORIZONTAL);
		rightArrow.setLayoutData(rightArrowLayoutData);
 
		shell.open();
		while(!shell.isDisposed()) {
			if(!display.readAndDispatch()) {
				display.sleep();
			}
		}
		shell.dispose();
		display.dispose();
	}
}
Que faut-il faire pour avoir " L Le titre R " ?

Merci à vous

Gal'