c.setLayoutData(new GridData(width, height));
GridData data = new GridData(); data.widthHint = width; data.heightHint = height; c.setLayoutData(data);
public void test_windowDrawing() {	PerformanceMeter meter = createMeter("Draw on a window");	int samples;		for(samples = 0; samples < 10; samples++) {		int width = 640;		int height = 480;		Shell shell = new Shell(display);		shell.setLayout(new GridLayout());		Canvas c = new Canvas(shell, SWT.NONE);		c.setLayoutData(new GridData(width, height));		shell.pack();		shell.open();		while(display.readAndDispatch());		Color color1 = new Color(display, 0xff, 0, 0xff);		Color color2 = new Color(display, 0, 0xff, 0xff);		int x1 = 0, y1 = height/2, x2 = width/2, y2 = 0;		meter.start();		GC gc = new GC(c);		for(int i = 0; i < 2000; i++) {			x1 = (x1 + 5) % width; y1 = (y1 + 5) % height; x2 = (x2 + 5) % width; y2 = (y2 + 5) % height;			gc.drawLine(x1, y1, x2, y2);			gc.setForeground((i & 1) == 0 ? color1 : color2);			gc.setBackground((i & 1) == 0 ? color1 : color2);			gc.fillRectangle(x1, y1, 200, 200);			gc.drawRoundRectangle(x2, y2, 200, 200, 50, 50);			gc.setLineStyle(SWT.LINE_DASHDOT);			gc.drawLine(x2, y1, x1, y2);		}		gc.dispose();		meter.stop();		shell.dispose();		color1.dispose();		color2.dispose();		while(display.readAndDispatch());	}		disposeMeter(meter);}