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 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
|
public void createControl(Composite parent) {
Composite composite = new Composite(parent, SWT.NONE);
GridLayout gl = new GridLayout();
int ncol = 6;
gl.numColumns = ncol;
composite.setLayout(gl);
// 1er ligne avec 6 boutons
Button button1 = new Button(composite, SWT.PUSH);
button1.setText("Button 1");
GridData gd = new GridData(GridData.FILL,GridData.CENTER,true,false);
button1.setLayoutData(gd);
Button button2 = new Button(composite, SWT.PUSH);
button2.setText("Button 2");
gd = new GridData(GridData.FILL,GridData.CENTER,true,false);
button2.setLayoutData(gd);
Button button3 = new Button(composite, SWT.PUSH);
button3.setText("Button 3");
gd = new GridData(GridData.FILL,GridData.CENTER,true,false);
button3.setLayoutData(gd);
Button button4 = new Button(composite, SWT.PUSH);
button4.setText("Button 4");
gd = new GridData(GridData.FILL,GridData.CENTER,true,false);
button4.setLayoutData(gd);
Button button5 = new Button(composite, SWT.PUSH);
button5.setText("Button 5");
gd = new GridData(GridData.FILL,GridData.CENTER,true,false);
button5.setLayoutData(gd);
Button button6 = new Button(composite, SWT.PUSH);
button6.setText("Button 6");
gd = new GridData(GridData.FILL,GridData.CENTER,true,false);
button6.setLayoutData(gd);
//Un séparateur
createLine(composite, nColumns);
// 2eme ligne avec 3 boutons
Button button7 = new Button(composite, SWT.PUSH);
button7.setText("Button 7");
gd = new GridData(GridData.BEGINNING,GridData.CENTER,true,false);
gd.horizontalSpan=2;
button7.setLayoutData(gd);
Button button8 = new Button(composite, SWT.PUSH);
button8.setText("Button 8");
gd = new GridData(GridData.CENTER,GridData.CENTER,true,false);
button8.setLayoutData(gd);
Button button9 = new Button(composite, SWT.PUSH);
button9.setText("Button 9");
gd = new GridData(GridData.END,GridData.CENTER,true,false);
gd.horizontalSpan=3;
button9.setLayoutData(gd);
setControl(composite);
}
/**
* Création d'une ligne de séparation
* @param parent
* @param ncol
*/
private void createLine(Composite parent, int ncol) {
Label line = new Label(parent, SWT.SEPARATOR|SWT.HORIZONTAL|SWT.BOLD);
GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
gridData.horizontalSpan = ncol;
line.setLayoutData(gridData);
} |
Partager