Java Code Examples for org.eclipse.swt.widgets.Control#setBackground()
The following examples show how to use
org.eclipse.swt.widgets.Control#setBackground() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TextWidget.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
protected void configureBackground(Control control) { final Color backgroundColor = control.getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND); final Color whiteColor = control.getDisplay().getSystemColor(SWT.COLOR_WHITE); if (toolkit.isPresent()) { if (control instanceof Composite) { toolkit.get().adapt((Composite) control); } else { toolkit.get().adapt(control, true, true); } } control.setBackground(readOnly ? backgroundColor : whiteColor); control.setEnabled(!readOnly); }
Example 2
Source File: SliderEditor.java From gama with GNU General Public License v3.0 | 5 votes |
@Override protected Composite createToolbar2() { final Composite t = super.createToolbar2(); t.setBackground(getNormalBackground()); for (final Control c : t.getChildren()) { c.setBackground(getNormalBackground()); } return t; }
Example 3
Source File: RenameInformationPopup.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private static void recursiveSetBackgroundColor(Control control, Color color) { control.setBackground(color); if (control instanceof Composite) { Control[] children= ((Composite) control).getChildren(); for (int i= 0; i < children.length; i++) { recursiveSetBackgroundColor(children[i], color); } } }
Example 4
Source File: EditorsDialog.java From gama with GNU General Public License v3.0 | 5 votes |
/** * Method createContents() * * @see org.eclipse.jface.dialogs.Dialog#createContents(org.eclipse.swt.widgets.Composite) */ @Override protected Control createContents(final Composite parent) { final Control composite = super.createContents(parent); composite.setBackground(IGamaColors.WHITE.color()); return composite; }
Example 5
Source File: SharedUiPlugin.java From Pydev with Eclipse Public License 1.0 | 5 votes |
public static void fixSelectionStatusDialogStatusLineColor(Object dialog, Color color) { //TODO: Hack: remove when MessageLine is styleable. try { Field field = org.eclipse.ui.dialogs.SelectionStatusDialog.class .getDeclaredField("fStatusLine"); field.setAccessible(true); Control messageLine = (Control) field.get(dialog); messageLine.setBackground(color); } catch (Exception e) { Log.log(e); } }
Example 6
Source File: ToolkitControl.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 5 votes |
private void updateBackground(Composite composite, Color background) { composite.setBackground(background); for (Control control : composite.getChildren()) { if (control instanceof Composite) { updateBackground((Composite) control, background); } else { control.setBackground(background); } } }
Example 7
Source File: ChartUIUtil.java From birt with Eclipse Public License 1.0 | 5 votes |
public static void setBackgroundColor( Control control, boolean selected, Color color ) { if ( control != null && !control.isDisposed( ) ) { if ( selected ) { control.setBackground( color ); } else { control.setBackground( null ); } } }
Example 8
Source File: RenameInformationPopup.java From typescript.java with MIT License | 5 votes |
private static void recursiveSetBackgroundColor(Control control, Color color) { control.setBackground(color); if (control instanceof Composite) { Control[] children= ((Composite) control).getChildren(); for (int i= 0; i < children.length; i++) { recursiveSetBackgroundColor(children[i], color); } } }
Example 9
Source File: HoverInfoWithSpellingAnnotation.java From xds-ide with Eclipse Public License 1.0 | 5 votes |
private void setColorAndFont(Control control, Color foreground, Color background, Font font) { control.setForeground(foreground); control.setBackground(background); control.setFont(font); if (control instanceof Composite) { Control[] children= ((Composite) control).getChildren(); for (Control element : children) { setColorAndFont(element, foreground, background, font); } } }
Example 10
Source File: HoverInformationControl.java From xds-ide with Eclipse Public License 1.0 | 5 votes |
@Override public void setBackgroundColor(Color background) { super.setBackgroundColor(background); Control[] children= fParent.getChildren(); for (Control element : children) { element.setBackground(background); } }
Example 11
Source File: SkypeStyleChatDisplay.java From saros with GNU General Public License v2.0 | 5 votes |
@Override public void updateEntityColor(final Object entity, final Color color) { for (Control control : contentComposite.getChildren()) { if (!entity.equals(control.getData())) continue; if (control instanceof ChatLineSeparator || control instanceof ChatLinePartnerChangeSeparator) control.setBackground(color); } }
Example 12
Source File: DataDefinitionTextManager.java From birt with Eclipse Public License 1.0 | 5 votes |
public void refreshAll( ) { // remove disposed control checkAll( ); Set<String> usedColorKeys = new HashSet<String>( ); ColorPalette colorPalette = ColorPalette.getInstance( ); // update all text for ( Map.Entry<Control, IQueryExpressionManager> entry : textCollection.entrySet( ) ) { Control text = entry.getKey( ); IQueryExpressionManager iqem = entry.getValue( ); String expr = iqem.getQuery( ).getDefinition( ); iqem.updateText( expr ); String name = exprCodec.getBindingName( iqem.getExpressionButton( ) .getExpression( ) ); if ( name != null ) { colorPalette.putColor( name ); usedColorKeys.add( name ); text.setBackground( colorPalette.getColor( name ) ); } else { text.setBackground( null ); } } // re-organize colors ColorPalette.getInstance( ).updateKeys( getAllUsedBindingNames( ) ); }
Example 13
Source File: PopupDialog.java From SWET with MIT License | 5 votes |
/** * Set the specified background color for the specified control and all of * its children, except for those specified in the list of exclusions. * * @param color * the color to use as the background color * @param control * the control whose color is to be changed * @param exclusions * a list of controls who are to be excluded from getting their * color assigned */ private void applyBackgroundColor(Color color, Control control, List<Object> exclusions) { if (!exclusions.contains(control)) { control.setBackground(color); } if (control instanceof Composite) { Control[] children = ((Composite) control).getChildren(); for (int i = 0; i < children.length; i++) { applyBackgroundColor(color, children[i], exclusions); } } }
Example 14
Source File: ControlListItem.java From thym with Eclipse Public License 1.0 | 5 votes |
@Override public void setBackground(Color color) { super.setBackground(color); Control[] children = getChildren(); for (Control child : children) { child.setBackground(color); } }
Example 15
Source File: PropsUi.java From hop with Apache License 2.0 | 4 votes |
public void setLook( final Control control, int style ) { if ( this.isOSLookShown() && style != WIDGET_STYLE_FIXED ) { return; } final GuiResource gui = GuiResource.getInstance(); Font font = null; Color background = null; switch ( style ) { case WIDGET_STYLE_DEFAULT: background = gui.getColorBackground(); if ( control instanceof Group && OS.indexOf( "mac" ) > -1 ) { control.addPaintListener( paintEvent -> { paintEvent.gc.setBackground( gui.getColorBackground() ); paintEvent.gc.fillRectangle( 2, 0, control.getBounds().width - 8, control.getBounds().height - 20 ); } ); } font = null; // GuiResource.getInstance().getFontDefault(); break; case WIDGET_STYLE_FIXED: if ( !this.isOSLookShown() ) { background = gui.getColorBackground(); } font = gui.getFontFixed(); break; case WIDGET_STYLE_TABLE: background = gui.getColorBackground(); font = null; // gui.getFontGrid(); break; case WIDGET_STYLE_NOTEPAD: background = gui.getColorBackground(); font = gui.getFontNote(); break; case WIDGET_STYLE_GRAPH: background = gui.getColorBackground(); font = gui.getFontGraph(); break; case WIDGET_STYLE_TOOLBAR: background = GuiResource.getInstance().getColorDemoGray(); break; case WIDGET_STYLE_TAB: background = GuiResource.getInstance().getColorWhite(); CTabFolder tabFolder = (CTabFolder) control; tabFolder.setSimple( false ); tabFolder.setBorderVisible( true ); // need to make a copy of the tab selection background color to get around PDI-13940 Color c = GuiResource.getInstance().getColorTab(); Color tabColor = new Color( c.getDevice(), c.getRed(), c.getGreen(), c.getBlue() ); tabFolder.setSelectionBackground( tabColor ); break; default: background = gui.getColorBackground(); font = null; // gui.getFontDefault(); break; } if ( font != null && !font.isDisposed() ) { control.setFont( font ); } if ( background != null && !background.isDisposed() ) { if ( control instanceof Button ) { Button b = (Button) control; if ( ( b.getStyle() & SWT.PUSH ) != 0 ) { return; } } control.setBackground( background ); } }
Example 16
Source File: TmfAbstractToolTipHandler.java From tracecompass with Eclipse Public License 2.0 | 4 votes |
default void setupControl(Control control) { control.setForeground(control.getDisplay().getSystemColor(SWT.COLOR_LIST_FOREGROUND)); control.setBackground(control.getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND)); }
Example 17
Source File: PropsUI.java From pentaho-kettle with Apache License 2.0 | 4 votes |
public void setLook( final Control control, int style ) { if ( this.isOSLookShown() && style != WIDGET_STYLE_FIXED ) { return; } final GUIResource gui = GUIResource.getInstance(); Font font = null; Color background = null; switch ( style ) { case WIDGET_STYLE_DEFAULT: background = gui.getColorBackground(); if ( control instanceof Group && OS.indexOf( "mac" ) > -1 ) { control.addPaintListener( new PaintListener() { @Override public void paintControl( PaintEvent paintEvent ) { paintEvent.gc.setBackground( gui.getColorBackground() ); paintEvent.gc.fillRectangle( 2, 0, control.getBounds().width - 8, control.getBounds().height - 20 ); } } ); } font = null; // GUIResource.getInstance().getFontDefault(); break; case WIDGET_STYLE_FIXED: if ( !this.isOSLookShown() ) { background = gui.getColorBackground(); } font = gui.getFontFixed(); break; case WIDGET_STYLE_TABLE: background = gui.getColorBackground(); font = null; // gui.getFontGrid(); break; case WIDGET_STYLE_NOTEPAD: background = gui.getColorBackground(); font = gui.getFontNote(); break; case WIDGET_STYLE_GRAPH: background = gui.getColorBackground(); font = gui.getFontGraph(); break; case WIDGET_STYLE_TOOLBAR: background = GUIResource.getInstance().getColorDemoGray(); break; case WIDGET_STYLE_TAB: background = GUIResource.getInstance().getColorWhite(); CTabFolder tabFolder = (CTabFolder) control; tabFolder.setSimple( false ); tabFolder.setBorderVisible( true ); // need to make a copy of the tab selection background color to get around PDI-13940 Color c = GUIResource.getInstance().getColorTab(); Color tabColor = new Color( c.getDevice(), c.getRed(), c.getGreen(), c.getBlue() ); tabFolder.setSelectionBackground( tabColor ); break; default: background = gui.getColorBackground(); font = null; // gui.getFontDefault(); break; } if ( font != null && !font.isDisposed() ) { control.setFont( font ); } if ( background != null && !background.isDisposed() ) { if ( control instanceof Button ) { Button b = (Button) control; if ( ( b.getStyle() & SWT.PUSH ) != 0 ) { return; } } control.setBackground( background ); } }
Example 18
Source File: EditorsDialog.java From gama with GNU General Public License v3.0 | 4 votes |
@Override protected Control createButtonBar(final Composite parent) { final Control composite = super.createButtonBar(parent); composite.setBackground(IGamaColors.WHITE.color()); return composite; }
Example 19
Source File: PageContainer.java From nebula with Eclipse Public License 2.0 | 4 votes |
public void adapt(Control control) { control.setBackground(getDisplay().getSystemColor(SWT.COLOR_WHITE)); }
Example 20
Source File: CustomAbstractInformationControl.java From APICloud-Studio with GNU General Public License v3.0 | 2 votes |
/** * Utility to set the foreground and the background color of the given control * * @param control * the control to modify * @param foreground * the color to use for the foreground * @param background * the color to use for the background */ private static void setColor(Control control, Color foreground, Color background) { control.setForeground(foreground); control.setBackground(background); }