| 12
 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
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
 
 |  
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.ScrolledComposite;
import org.eclipse.swt.events.ControlAdapter;
import org.eclipse.swt.events.ControlEvent;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
 
public class Exemple {
 
    public static void createControl(Composite parent) {
        final Composite top = new Composite(parent, SWT.BORDER);
        top.setLayout(new GridLayout(2,true));
        final Button btn1 = new Button(top, SWT.PUSH);
        btn1.setText("Bouton 1");
        btn1.setLayoutData(new GridData(GridData.BEGINNING, GridData.FILL, false,true));
 
        final Button btn2 = new Button(top, SWT.PUSH);
        btn2.setText("Bouton 1");
        btn2.setLayoutData(new GridData(GridData.END, GridData.FILL, false,true));
 
 
        final ScrolledComposite sc = new ScrolledComposite(parent, SWT.V_SCROLL|SWT.H_SCROLL);
        sc.setExpandHorizontal(true);
        sc.setExpandVertical(true);
        sc.setMinSize(0, 0);
        sc.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true));
 
        // Là tu as ton code initial
        final Composite composite = new Composite(sc, SWT.NONE);
        composite.setLayout(new GridLayout(2, true));
 
        GridLayout layout = new GridLayout();
        GridData gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
 
        layout.verticalSpacing = 15;
        composite.setLayout(layout);
        layout.numColumns = 2;
        layout.marginTop = 10;
        layout.horizontalSpacing = 200;
 
        final Button dir = new Button(composite, SWT.RADIO);
        dir.setText("Grammaire direct");
        final Button ext = new Button(composite, SWT.RADIO);
        ext.setText("Grammaire externe");
 
        // il ya 17 autre label crée apres celui la : j'ai fais joujou !
        for (int i = 0; i < 18; i++) {
            Label label = new Label(composite, SWT.NORMAL);
            label.setText("Version " + i);
            final Text text = new Text(composite, SWT.HIDE_SELECTION | SWT.BORDER);
            gridData.horizontalIndent = -240;
            text.setLayoutData(gridData);
        }
 
        // Important !
        composite.addControlListener(new ControlAdapter() {
 
            public void controlResized(ControlEvent e) {
                Point s = composite.computeSize(SWT.DEFAULT, SWT.DEFAULT);
                sc.setMinSize(s);
 
            }
 
        });
 
        sc.setContent(composite);
        Point s = composite.computeSize(SWT.DEFAULT, SWT.DEFAULT);
        sc.setMinSize(s);
 
 
    }
 
 
 
    public static void main(String[] args) {
        Display display = new Display();
        Shell shell = new Shell(display);
        shell.setLayout(new GridLayout(1,false));
 
        createControl(shell);
 
        shell.open();
        while (!shell.isDisposed()) {
            if (!display.readAndDispatch())
                display.sleep();
        }
        display.dispose();
    }
 
 
} |