StringBuffer generateCode () {
		/* Make sure all information being entered is stored in the table */
		resetEditors ();
		
		/* Get names for controls in the layout */
		names = new String [children.length];
		for (int i = 0; i < children.length; i++) {
			TableItem myItem = table.getItem(i);
			String name = myItem.getText(0);
			if (name.matches("\\d")) {
				Control control = children [i];
				String controlClass = control.getClass ().toString ();
				String controlType = controlClass.substring (controlClass.lastIndexOf ('.') + 1);
				names [i] = controlType.toLowerCase () + i;
			} else {
				names [i] = myItem.getText(0);
			}	
		}
	
		/* Create StringBuffer containing the code */
		StringBuffer code = new StringBuffer ();
		code.append ("import org.eclipse.swt.*;\n");
		code.append ("import org.eclipse.swt.layout.*;\n");
		code.append ("import org.eclipse.swt.widgets.*;\n");
		if (needsCustom ()) code.append ("import org.eclipse.swt.custom.*;\n");
		if (needsGraphics ()) code.append ("import org.eclipse.swt.graphics.*;\n");
		code.append ("\n");
		code.append ("public class MyLayout {\n");
		code.append ("\tpublic static void main (String [] args) {\n");
		code.append ("\t\tDisplay display = new Display ();\n");
		code.append ("\t\tShell shell = new Shell (display);\n");
		
		/* Get layout specific code */
		code.append (generateLayoutCode ());
		
		code.append ("\n\t\tshell.pack ();\n\t\tshell.open ();\n\n");
		code.append ("\t\twhile (!shell.isDisposed ()) {\n");
		code.append ("\t\t\tif (!display.readAndDispatch ())\n");
		code.append ("\t\t\t\tdisplay.sleep ();\n\t\t}\n\t\tdisplay.dispose ();\n\t}\n}");
		
		return code;
	}