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 (); }
RGB rgb = foregroundDialog.open(); if (rgb == null) return; Color oldColor = itemForegroundColor; itemForegroundColor = new Color (itemForegroundButton.getDisplay(), rgb); setItemsForeground (); if (oldColor != null) oldColor.dispose ();
			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 ();				}			}