ColorDialog colorDialog= new ColorDialog(backgroundButton.getShell()); colorDialog.setRGB(chosenBackgroundColor); RGB newColor = colorDialog.open(); if (newColor != null) { Color oldColor = null; if (backgroundColor != null) oldColor = backgroundColor; backgroundColor = new Color (backgroundButton.getDisplay(), newColor); GC gc = new GC(backgroundImage); gc.setBackground(backgroundColor); gc.fillRectangle(0,0,fontHeight*2-1,fontHeight-1); gc.drawRectangle(0,0,fontHeight*2-1,fontHeight-1); gc.dispose(); backgroundButton.setImage(backgroundImage); chosenBackgroundColor = newColor; setColors (); if (oldColor != null) oldColor.dispose (); }
RGB rgb = backgroundDialog.open(); if (rgb == null) return; Color oldColor = backgroundColor; backgroundColor = new Color (backgroundButton.getDisplay(), rgb); setExampleWidgetBackground (); if (oldColor != null) oldColor.dispose ();
			public void widgetSelected(SelectionEvent event) {				ColorDialog colorDialog= new ColorDialog(backgroundButton.getShell());				colorDialog.setRGB(chosenBackgroundColor);				RGB newColor = colorDialog.open();				if (newColor != null) {					Color oldColor = null;					if (backgroundColor != null) oldColor = backgroundColor;					backgroundColor = new Color (backgroundButton.getDisplay(), newColor);					GC gc = new GC(backgroundImage);					gc.setBackground(backgroundColor);					gc.fillRectangle(0,0,fontHeight*2-1,fontHeight-1);					gc.drawRectangle(0,0,fontHeight*2-1,fontHeight-1);					gc.dispose();					backgroundButton.setImage(backgroundImage);					chosenBackgroundColor = newColor;					setColors ();					if (oldColor != null) oldColor.dispose ();				}			}