gt: 			return get_event_header() + get_event_code() + get_event_end(0);
context: package g4p.tool.controls;
  
  import g4p.tool.Messages;
  import g4p.tool.TDataConstants;
  import g4p.tool.TFileConstants;
  import g4p.tool.TGuiConstants;
  import g4p.tool.gui.GuiDesigner;
  import g4p.tool.gui.propertygrid.CtrlPropModel;
  import g4p.tool.gui.propertygrid.Validator;
  import g4p.tool.gui.tabview.WindowView.MutableDBase;
  import g4p_controls.GCScheme;
  
  import java.awt.Color;
  import java.awt.Graphics2D;
  import java.awt.geom.AffineTransform;
  import java.awt.image.BufferedImage;
  import java.io.File;
  import java.io.IOException;
  import java.io.Serializable;
  import java.util.ArrayList;
  import java.util.Enumeration;
  
  import javax.imageio.ImageIO;
  import javax.swing.tree.DefaultMutableTreeNode;
  
  import processing.app.Editor;
  
  /**
   * Every control in the G4P library has its equivalent class in this package, for instance
   * GButton --> DButton. The classes in this package provide information about the properties
   * available in the property grid for a particular component. <br>
   * If an attribute identifier in one of these classes starts with an underscore followed by a
   * 4 digit numbers then it is to become a property e.g. <pre>_0131_height</pre><br>
   * The 4 digit number is used to decide the order properties should appear in the property
   * grid. <br>
   * The part after the second underscore is the property name and this is used to provide 
   * additional information about the property, so for <pre>_0131_height</pre><br>
   * <pre>height_label</pre> is the text that describes the property in the grid. <br>
   * <pre>height_edit</pre> can the property be edited. <br>
   * <pre>height_show</pre> is the property visible in the grid. <br>
   * <pre>height_tooltip</pre> the tooltip text for the property grid. <br>
   * <pre>height_editor</pre> the object used to edit the property. <br>
   * <pre>height_validator</pre> the object used to validate the proerty value. <br>
   * <pre>height_updater</pre> the name of the method to call after the property has changed. <br>
   * 
   * If an editor and or validator is not specified for each property a default one based on the 
   * data type is provided. <br>
   * 
   * The program uses reflection to get these attributes which are used to create a table
   * model (CtrlPropModel class) for the property grid table (CtrlPropView class). <br>
   * 
   * @author Peter Lager
   *
   */
  @SuppressWarnings("serial")
  public abstract class DBase extends DefaultMutableTreeNode implements Serializable, TDataConstants, TFileConstants, TGuiConstants {
  
  	/**
  	 * This method was added to overcome a problem using the MessageFormat class where
  	 * the locale insisted in inserting thousand separators in numbers.
  	 * Instead of passing an int to MessageFormat this method means we can pass a String. 
  	 */
  	protected static String $(int i){
  		return String.valueOf(i);
  	}
  	
  	/**
  	 * This method was added to overcome a problem using the MessageFormat class where
  	 * the locale insisted in inserting thousand separators in numbers.
  	 * Instead of passing a float to MessageFormat this method means we can pass a String. 
  	 */
  	protected static String $(float f){
  		return String.valueOf(f);
  	}
  	
  	/**
  	 * The property model used in the table view
  	 */
  	transient public CtrlPropModel propertyModel;
  
  	// Whether it is selectable in the WindowView
  	// set to false for DOptionGroup and DTimer
  	protected boolean selectable = true;
  	// can the control be resized?
  	protected boolean resizeable = true;
  	// Can the control be moved
  	protected boolean moveable = true;
  
  	// The name of the equivalent class in G4P
  	public String componentClass = "";
  
  	// Global Colour scheme
  	public static int globalColorScheme = GCScheme.BLUE_SCHEME; // Blue
  	public static Color[] globalJpalette = GCScheme.getJavaColor(globalColorScheme);
  	
  	// Unique id numbers to identify event handlers and used to capture
  	// user code.
  	public Integer[] id = new Integer[1];
  	
  	public String 		_0010_name = "APPLICATION";
  	public String 		name_label = "Variable Name";
  	public String 		name_tooltip = "Use Java naming rules";
  	public Boolean 		name_edit = true;
  	public Boolean 		name_show = true;
  	public Validator 	name_validator = Validator.getValidator(COMPONENT_NAME);
  
  	public int 			_0820_x = 0;
  	public String 		x_label = "X";
  	public String 		x_tooltip = "pixels";
  	public Boolean 		x_edit = true;
  	public Boolean 		x_show = true;
  	public Validator 	x_validator = Validator.getValidator(int.class, -9999, 9999);
  
  	public int 			_0821_y = 0;
  	public String 		y_label = "Y";
  	public String 		y_tooltip = "pixels";
  	public Boolean 		y_edit = true;
  	public Boolean 		y_show = true;
  	public Validator 	y_validator = x_validator;
  
  	public int 			_0826_width = 0;
  	public String 		width_label = "Width";
  	public String 		width_tooltip = "pixels";
  	public Boolean 		width_edit = true;
  	public Boolean 		width_show = true;
  	public Validator 	width_validator = Validator.getValidator(int.class, 10, 9999);
  
  	public int 			_0827_height = 0;
  	public String 		height_label = "Height";
  	public String 		height_tooltip = "pixels";
  	public Boolean 		height_edit = true;
  	public Boolean 		height_show = true;
  	public Validator 	height_validator = width_validator;
  
  	public String		_0020_eventHandler = "Event handler";
  	public String 		eventHandler_label = "Event method";
  	public String 		eventHandler_tooltip = "unique name for event handler method";
  	public Boolean 		eventHandler_edit = true;
  	public Boolean 		eventHandler_show = true;
  	public Validator 	eventHandler_validator = Validator.getValidator(COMPONENT_NAME_0);  // modified 09-02-2013 to allow zero length
  
  	public Boolean 		_0600_opaque  = false;
  	public Boolean 		opaque_edit = true;
  	public Boolean 		opaque_show = true;
  	public String 		opaque_label = "Opaque background?";
  
  	/**
  	 * 
  	 */
  	public DBase(){
  		allowsChildren = true;
  		id[0] = IdGen.instance().getNext();
  	}
  
  	// ==========================================================================
  	// ==========================================================================
  	// ===========   Stuff for control declaration and  generation   ============
  	// ==========================================================================
  	
  	/**
  	 * Recursive function to get the event methods for all controls
  	 * 
  	 * @param lines
  	 */
  	public void make_event_method(ArrayList<String> lines){
  		String methodDef = get_event_definition();
  		if(methodDef != null)
  			lines.add(methodDef);
  		if(allowsChildren){
  			Enumeration<?> e = children();
  			while(e.hasMoreElements()){
  				((DBase)e.nextElement()).make_event_method(lines);
  			}
  		}		
  	}
  
  	/**
  	 * Recursive function to get the variable declaration.
  	 * 
  	 * @param lines
  	 */
  	public void make_declaration(ArrayList<String> lines){
  		String decl = get_declaration();
  		if(decl != null)
  			lines.add(decl);
  		if(allowsChildren){
  			Enumeration<?> e = children();
  			while(e.hasMoreElements()){
  				((DBase)e.nextElement()).make_declaration(lines);
  			}
  		}		
  	}
  
  	/**
  	 * Recursive function to first get the creator code for this
  	 * component then repeat for any children. <br>
  	 * This method is overridden in DWindow, DPanel and DOptionGroup.
  	 * 
  	 * @param lines
  	 * @param parent the control that has this as a child default = null
  	 * @param window the window responsible for drawing this control default = "this" 
  	 */
  	public void make_creator(ArrayList<String> lines, DBase parent, String window){
  		DBase comp;
  		Enumeration<?> e;
  		String ccode = get_creator(parent, window);
  		if(ccode != null && !ccode.equals(""))
  			lines.add(ccode);
  		if(allowsChildren){
  			e = children();
  			while(e.hasMoreElements()){
  				comp = (DBase)e.nextElement();
  				comp.make_creator(lines, this, window);
  			}
  		}				
  	}
  	
  
  	// ==========================================================================
  	// ==========================================================================
  	// =================   Stuff for event code generation   ====================
  	// ==========================================================================
  
  	/**
  	 * Get the declaration for this control <pre>Foo variable_name;</pre><br>
  	 */
  	protected String get_declaration(){
  		return componentClass + " " + _0010_name+ "; \n";
  	}
  
  	/**
  	 * Get the creator statement <pre>var = new Foo(...);</pre><br>
  	 * Override this method in all classes.
  	 */
  	protected String get_creator(DBase parent, String window){
  		String s = "";
  		if(opaque_show)
  			s = Messages.build(SET_OPAQUE, _0010_name, _0600_opaque);
  		return s;
  	}
  	
  	/** 
  	 * Get the event method for this control.
  	 * 
  	 * Used for everything except DWindow
  	 * Modified 09-02-2013 to return null if no method name
  	 * 
  	 */
  	protected String get_event_definition(){
  		if(_0020_eventHandler.length() > 0)
  