else {style = new StyleRange(i, 1, range.foreground, range.background, range.fontStyle | SWT.ITALIC);};
else {style = new StyleRange(i, 1, range.foreground, range.background, range.fontStyle | SWT.ITALIC);}
	void createStyledTextStyleGroup () {		final Display display = controlGroup.getDisplay ();		styledTextStyleGroup = new Group (controlGroup, SWT.NONE);		styledTextStyleGroup.setText (ControlExample.getResourceString ("StyledText_Styles"));		styledTextStyleGroup.setLayout (new GridLayout(5, false));		GridData data = new GridData (GridData.HORIZONTAL_ALIGN_FILL);		data.horizontalSpan = 2;		styledTextStyleGroup.setLayoutData (data);				/* Get images */		boldImage = createBitmapImage (display, "bold");		italicImage = createBitmapImage (display, "italic");		redImage = createBitmapImage (display, "red");		yellowImage = createBitmapImage (display, "yellow");				/* Create controls to modify the StyledText */		Label label = new Label (styledTextStyleGroup, SWT.NONE);		label.setText (ControlExample.getResourceString ("StyledText_Style_Instructions"));		data = new GridData(GridData.FILL_HORIZONTAL);		data.horizontalSpan = 5;		label.setLayoutData(data);		new Label (styledTextStyleGroup, SWT.NONE).setText (ControlExample.getResourceString ("Bold"));		boldButton = new Button (styledTextStyleGroup, SWT.PUSH);		boldButton.setImage (boldImage);		boldButton.addSelectionListener(new SelectionAdapter () {			public void widgetSelected (SelectionEvent e) {				Point sel = styledText.getSelectionRange();				if ((sel == null) || (sel.y == 0)) return;				StyleRange style;				for (int i = sel.x; i<sel.x+sel.y; i++) {					StyleRange range = styledText.getStyleRangeAtOffset(i);					if (range == null) {style = new StyleRange(i, 1, null, null, SWT.BOLD);}					else {style = new StyleRange(i, 1, range.foreground, range.background, range.fontStyle | SWT.BOLD);};					styledText.setStyleRange(style);				}				styledText.setSelectionRange(sel.x + sel.y, 0);			}		});		new Label (styledTextStyleGroup, SWT.NONE).setLayoutData(new GridData(GridData.FILL_HORIZONTAL));		new Label (styledTextStyleGroup, SWT.NONE).setText (ControlExample.getResourceString ("Foreground_Style"));		redButton = new Button (styledTextStyleGroup, SWT.PUSH);		redButton.setImage (redImage);		new Label (styledTextStyleGroup, SWT.NONE).setText (ControlExample.getResourceString ("Italic"));		italicButton = new Button (styledTextStyleGroup, SWT.PUSH);		italicButton.setImage (italicImage);		italicButton.addSelectionListener(new SelectionAdapter () {			public void widgetSelected (SelectionEvent e) {				Point sel = styledText.getSelectionRange();				if ((sel == null) || (sel.y == 0)) return;				StyleRange style;				for (int i = sel.x; i<sel.x+sel.y; i++) {					StyleRange range = styledText.getStyleRangeAtOffset(i);					if (range == null) {style = new StyleRange(i, 1, null, null, SWT.ITALIC);}					else {style = new StyleRange(i, 1, range.foreground, range.background, range.fontStyle | SWT.ITALIC);};					styledText.setStyleRange(style);				}				styledText.setSelectionRange(sel.x + sel.y, 0);			}		});		new Label (styledTextStyleGroup, SWT.NONE).setLayoutData(new GridData(GridData.FILL_HORIZONTAL));		new Label (styledTextStyleGroup, SWT.NONE).setText (ControlExample.getResourceString ("Background_Style"));		yellowButton = new Button (styledTextStyleGroup, SWT.PUSH);		yellowButton.setImage (yellowImage);		SelectionListener colorListener = new SelectionAdapter () {			public void widgetSelected (SelectionEvent e) {				Point sel = styledText.getSelectionRange();				if ((sel == null) || (sel.y == 0)) return;				Color fg, bg;				if (e.widget == redButton) {					fg = display.getSystemColor (SWT.COLOR_RED);					bg = null;				} else if (e.widget == yellowButton) {					fg = null;					bg = display.getSystemColor (SWT.COLOR_YELLOW);				} else {					fg = bg = null;				}				StyleRange style;				for (int i = sel.x; i<sel.x+sel.y; i++) {					StyleRange range = styledText.getStyleRangeAtOffset(i);					if (range == null) {						style = new StyleRange(i, 1, fg, bg, SWT.NORMAL);					}					else {						if (range.foreground != null) fg = range.foreground;						if (range.background != null) bg = range.background;						style = new StyleRange(i, 1, fg, bg, range.fontStyle);					};					styledText.setStyleRange(style);				}				styledText.setSelectionRange(sel.x + sel.y, 0);			};		};		redButton.addSelectionListener(colorListener);		yellowButton.addSelectionListener(colorListener);		yellowButton.addDisposeListener(new DisposeListener () {			public void widgetDisposed (DisposeEvent e) {				boldImage.dispose();				italicImage.dispose();				redImage.dispose();				yellowImage.dispose();			}		});	}