itemBackgroundImage = null; itemForegroundImage = null;
	void createColorGroup () {		/* Get default system colors for the control */		table1 = new Table (tableGroup, SWT.NONE);		defaultBackgroundColor = table1.getBackground ();		defaultForegroundColor = table1.getForeground ();				super.createColorGroup();				tableItemGroup = new Group (colorGroup, SWT.NONE);		tableItemGroup.setText (ControlExample.getResourceString ("Item_Colors"));		GridData data = new GridData ();		data.horizontalSpan = 2;		tableItemGroup.setLayoutData (data);		tableItemGroup.setLayout (new GridLayout (2, false));		new Label (tableItemGroup, SWT.NONE).setText (ControlExample.getResourceString ("Item_Background_Color"));		itemBackgroundButton = new Button (tableItemGroup, SWT.PUSH);		new Label (tableItemGroup, SWT.NONE).setText (ControlExample.getResourceString ("Item_Foreground_Color"));		itemForegroundButton = new Button (tableItemGroup, SWT.PUSH);				/* Get default system colors for the control */		TableItem item = new TableItem (table1, SWT.NONE);		defaultItemBackgroundColor = item.getBackground();		defaultItemForegroundColor = item.getForeground();		table1.dispose ();				/* Create images to display current colors */		chosenItemBackgroundColor = defaultItemBackgroundColor.getRGB();		chosenItemForegroundColor = defaultItemForegroundColor.getRGB();		GC gc = new GC (fontButton.getShell());		final int fontHeight = gc.getFontMetrics().getHeight();		gc.dispose ();		itemBackgroundImage = new Image(colorGroup.getDisplay(),fontHeight*2,fontHeight);		gc = new GC(itemBackgroundImage);		gc.setBackground(defaultItemBackgroundColor);		gc.fillRectangle(0,0,fontHeight*2-1,fontHeight-1);		gc.drawRectangle(0,0,fontHeight*2-1,fontHeight-1);		gc.dispose();		itemForegroundImage = new Image(colorGroup.getDisplay(),fontHeight*2,fontHeight);		gc = new GC(itemForegroundImage);		gc.setBackground(defaultItemForegroundColor);		gc.fillRectangle(0,0,fontHeight*2-1,fontHeight-1);		gc.drawRectangle(0,0,fontHeight*2-1,fontHeight-1);		gc.dispose();				/* Add listeners to set the colors and font */		itemBackgroundButton.setImage(itemBackgroundImage);		itemBackgroundButton.addSelectionListener(new SelectionAdapter() {			public void widgetSelected(SelectionEvent event) {				itemSet = true;				ColorDialog colorDialog= new ColorDialog(itemBackgroundButton.getShell());				colorDialog.setRGB(chosenItemBackgroundColor);				RGB newColor = colorDialog.open();				if (newColor != null) {					Color oldColor = null;					if (itemBackgroundColor != null) oldColor = itemBackgroundColor;					itemBackgroundColor = new Color (itemBackgroundButton.getDisplay(), newColor);					GC gc = new GC(itemBackgroundImage);					gc.setBackground(itemBackgroundColor);					gc.fillRectangle(0,0,fontHeight*2-1,fontHeight-1);					gc.drawRectangle(0,0,fontHeight*2-1,fontHeight-1);					gc.dispose();					itemBackgroundButton.setImage(itemBackgroundImage);					chosenItemBackgroundColor = newColor;					setItemColors ();					if (oldColor != null) oldColor.dispose ();				}			}		});		itemForegroundButton.setImage(itemForegroundImage);		itemForegroundButton.addSelectionListener(new SelectionAdapter() {			public void widgetSelected(SelectionEvent event) {				itemSet = true;				ColorDialog colorDialog= new ColorDialog(itemForegroundButton.getShell());				colorDialog.setRGB(chosenItemForegroundColor);				RGB newColor = colorDialog.open();				if (newColor != null) {					Color oldColor = null;					if (itemForegroundColor != null) oldColor = itemForegroundColor;					itemForegroundColor = new Color (itemForegroundButton.getDisplay(), newColor);					GC gc= new GC(itemForegroundImage);					gc.setBackground(itemForegroundColor);					gc.fillRectangle(0,0,fontHeight*2-1,fontHeight-1);					gc.drawRectangle(0,0,fontHeight*2-1,fontHeight-1);					gc.dispose();					itemForegroundButton.setImage(itemForegroundImage);					chosenItemForegroundColor = newColor;					setItemColors ();					if (oldColor != null) oldColor.dispose ();				}			}		});		itemBackgroundButton.addDisposeListener(new DisposeListener() {			public void widgetDisposed(DisposeEvent event) {				if (itemBackgroundImage != null) itemBackgroundImage.dispose();				if (itemForegroundImage != null) itemForegroundImage.dispose();				if (itemBackgroundColor != null) itemBackgroundColor.dispose();				if (itemForegroundColor != null) itemForegroundColor.dispose();				itemBackgroundImage = null;				itemForegroundImage = null;				itemBackgroundColor = null;				itemForegroundColor = null;						}		});	}