Java Code Examples for org.eclipse.swt.widgets.Label#setBackground()
The following examples show how to use
org.eclipse.swt.widgets.Label#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: HopGuiPipelinePerfDelegate.java From hop with Apache License 2.0 | 5 votes |
/** * Tell the user that the pipeline is not running or that there is no monitoring configured. */ private void showEmptyGraph() { if ( perfComposite.isDisposed() ) { return; } emptyGraph = true; Label label = new Label( perfComposite, SWT.CENTER ); label.setText( BaseMessages.getString( PKG, "PipelineLog.Dialog.PerformanceMonitoringNotEnabled.Message" ) ); label.setBackground( perfComposite.getBackground() ); label.setFont( GuiResource.getInstance().getFontMedium() ); FormData fdLabel = new FormData(); fdLabel.left = new FormAttachment( 5, 0 ); fdLabel.right = new FormAttachment( 95, 0 ); fdLabel.top = new FormAttachment( 5, 0 ); label.setLayoutData( fdLabel ); Button button = new Button( perfComposite, SWT.CENTER ); button.setText( BaseMessages.getString( PKG, "PipelineLog.Dialog.PerformanceMonitoring.Button" ) ); button.setBackground( perfComposite.getBackground() ); button.setFont( GuiResource.getInstance().getFontMedium() ); button.addSelectionListener( new SelectionAdapter() { public void widgetSelected( SelectionEvent event ) { pipelineGraph.editProperties( pipelineGraph.getPipelineMeta(), hopGui, true, PipelineDialog.Tabs.MONITOR_TAB ); } } ); FormData fdButton = new FormData(); fdButton.left = new FormAttachment( 40, 0 ); fdButton.right = new FormAttachment( 60, 0 ); fdButton.top = new FormAttachment( label, 5 ); button.setLayoutData( fdButton ); perfComposite.layout( true, true ); }
Example 2
Source File: ClassFileEditor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private Label createLabel(Composite parent, String text) { Label label= new Label(parent, SWT.WRAP); if (text != null) label.setText(text); label.setBackground(fBackgroundColor); label.setForeground(fForegroundColor); GridData gd= new GridData(SWT.FILL, SWT.FILL, true, false); label.setLayoutData(gd); return label; }
Example 3
Source File: DayEditorCalendarableItemControl.java From nebula with Eclipse Public License 2.0 | 5 votes |
/** * Create the event control's layout */ private void initialize() { setBackground(BACKGROUND_COLOR); label = new Label(this, SWT.WRAP); label.setText("Label"); label.setBackground(BACKGROUND_COLOR); FillLayout fillLayout = new FillLayout(); fillLayout.marginHeight = MARGIN; fillLayout.marginWidth = MARGIN; setBackground(BORDER_COLOR); setLayout(fillLayout); addPaintListener(paintListener); label.addMouseListener(labelMouseListener); }
Example 4
Source File: ReportDocumentEditor.java From birt with Eclipse Public License 1.0 | 5 votes |
private Label createHeadingLabel( Composite parent, String text ) { Label label = new Label( parent, SWT.NONE ); if ( text != null ) label.setText( text ); label.setBackground( fBackgroundColor ); label.setForeground( fForegroundColor ); label.setFont( JFaceResources.getBannerFont( ) ); return label; }
Example 5
Source File: ClassFileEditor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private Label createTitleLabel(Composite parent, String text) { Label label = new Label(parent, SWT.NONE); if (text != null) label.setText(text); label.setBackground(fBackgroundColor); label.setForeground(fForegroundColor); label.setFont(JFaceResources.getHeaderFont()); fHeaderLabels.add(label); return label; }
Example 6
Source File: FormatSpecifierPreview.java From birt with Eclipse Public License 1.0 | 5 votes |
public FormatSpecifierPreview( Composite parent, int style, boolean isInEditor ) { super( parent, style ); this.isInEditor = isInEditor; setLayout( new FillLayout( ) ); lblPreview = new Label( this, SWT.NONE ); lblPreview.setBackground( parent.getBackground( ) ); }
Example 7
Source File: DisplayOverlay.java From gama with GNU General Public License v3.0 | 5 votes |
private Label label(final Composite c, final int horizontalAlign) { final Label l = new Label(c, SWT.None); l.setForeground(IGamaColors.WHITE.color()); l.setBackground(IGamaColors.BLACK.color()); l.setText(" "); l.setLayoutData(infoData(horizontalAlign)); l.addMouseListener(toggleListener); return l; }
Example 8
Source File: ImageViewer.java From eclipse-extras with Eclipse Public License 1.0 | 5 votes |
public ImageViewer( Composite parent ) { scrolledComposite = new ScrolledComposite( parent, SWT.H_SCROLL | SWT.V_SCROLL ); scrolledComposite.setBackground( getBackgroundColor() ); imageLabel = new Label( scrolledComposite, SWT.NONE ); imageLabel.setBackground( getBackgroundColor() ); scrolledComposite.setContent( imageLabel ); scrolledComposite.addListener( SWT.Dispose, this::handleDispose ); }
Example 9
Source File: XSPEditorUtil.java From XPagesExtensionLibrary with Apache License 2.0 | 5 votes |
static public Label createIndentedLabel(Composite parent, String labelText, int width, int indentAmt) { Label newLabel = new Label(parent, SWT.NONE); newLabel.setText(labelText); GridData ourGD = new GridData(SWT.BEGINNING, SWT.CENTER, false, false, width, 1); if (indentAmt != 0) ourGD.horizontalIndent = indentAmt; newLabel.setLayoutData(ourGD); newLabel.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND)); return newLabel; }
Example 10
Source File: TitledSeparator.java From nebula with Eclipse Public License 2.0 | 5 votes |
/** * @return a SWT label */ private Label createLabel() { final Label label = new Label(this, SWT.NONE); label.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, false, false)); label.setFont(getFont()); label.setForeground(getForeground()); label.setBackground(getBackground()); return label; }
Example 11
Source File: BonitaPreferenceDialog.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
protected Label createItemLabel(final Composite composite, final Color backgroundColor, final String text) { final Composite labelContainer = new Composite(composite, SWT.NONE); GridDataFactory.fillDefaults().hint(LABEL_WIDTH, SWT.DEFAULT).applyTo(labelContainer); final GridLayout layout = new GridLayout(1, true); layout.marginWidth = 0; layout.marginHeight = 0; labelContainer.setLayout(layout); labelContainer.setBackground(backgroundColor); layout.marginBottom = 0; final Label label = new Label(labelContainer, SWT.CENTER); GridDataFactory.fillDefaults().grab(true, false).align(SWT.CENTER, SWT.CENTER).applyTo(label); label.setText(text); label.setBackground(backgroundColor); return label; }
Example 12
Source File: TreeToolbar.java From pentaho-kettle with Apache License 2.0 | 4 votes |
public TreeToolbar( Composite composite, int i ) { super( composite, i ); FormLayout formLayout = new FormLayout(); formLayout.marginWidth = 0; formLayout.marginHeight = 0; formLayout.marginTop = 0; formLayout.marginBottom = 0; this.setLayout( formLayout ); Label sep3 = new Label( this, SWT.SEPARATOR | SWT.HORIZONTAL ); sep3.setBackground( GUIResource.getInstance().getColorWhite() ); FormData fdSep3 = new FormData(); fdSep3.left = new FormAttachment( 0, 0 ); fdSep3.right = new FormAttachment( 100, 0 ); fdSep3.top = new FormAttachment( 0 ); sep3.setLayoutData( fdSep3 ); ToolBar treeTb = new ToolBar( this, SWT.HORIZONTAL | SWT.FLAT ); props.setLook( treeTb, Props.WIDGET_STYLE_TOOLBAR ); /* This contains a map with all the unnamed transformation (just a filename) */ expandAll = new ToolItem( treeTb, SWT.PUSH ); expandAll.setImage( GUIResource.getInstance().getImageExpandAll() ); collapseAll = new ToolItem( treeTb, SWT.PUSH ); collapseAll.setImage( GUIResource.getInstance().getImageCollapseAll() ); FormData fdTreeToolbar = new FormData(); if ( Const.isLinux() ) { fdTreeToolbar.top = new FormAttachment( sep3, 3 ); } else { fdTreeToolbar.top = new FormAttachment( sep3, 5 ); } fdTreeToolbar.right = new FormAttachment( 100, -10 ); treeTb.setLayoutData( fdTreeToolbar ); ToolBar selectionFilterTb = new ToolBar( this, SWT.HORIZONTAL | SWT.FLAT ); props.setLook( selectionFilterTb, Props.WIDGET_STYLE_TOOLBAR ); ToolItem clearSelectionFilter = new ToolItem( selectionFilterTb, SWT.PUSH ); clearSelectionFilter.setImage( GUIResource.getInstance().getImageClearText() ); clearSelectionFilter.setDisabledImage( GUIResource.getInstance().getImageClearTextDisabled() ); FormData fdSelectionFilterToolbar = new FormData(); if ( Const.isLinux() ) { fdSelectionFilterToolbar.top = new FormAttachment( sep3, 3 ); } else { fdSelectionFilterToolbar.top = new FormAttachment( sep3, 5 ); } fdSelectionFilterToolbar.right = new FormAttachment( treeTb, -20 ); selectionFilterTb.setLayoutData( fdSelectionFilterToolbar ); selectionFilter = new Text( this, SWT.SINGLE | SWT.BORDER | SWT.LEFT | SWT.SEARCH ); FormData fdSelectionFilter = new FormData(); int offset = -( GUIResource.getInstance().getImageClearTextDisabled().getBounds().height + 6 ); if ( Const.isLinux() ) { offset = -( GUIResource.getInstance().getImageClearTextDisabled().getBounds().height + 13 ); } fdSelectionFilter.top = new FormAttachment( selectionFilterTb, offset ); fdSelectionFilter.right = new FormAttachment( selectionFilterTb, 0 ); fdSelectionFilter.left = new FormAttachment( 0, 10 ); selectionFilter.setLayoutData( fdSelectionFilter ); clearSelectionFilter.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected( SelectionEvent event ) { selectionFilter.setText( "" ); } } ); clearSelectionFilter.setEnabled( !Utils.isEmpty( selectionFilter.getText() ) ); selectionFilter.addModifyListener( modifyEvent -> { clearSelectionFilter.setEnabled( !Utils.isEmpty( selectionFilter.getText() ) ); } ); Label sep4 = new Label( this, SWT.SEPARATOR | SWT.HORIZONTAL ); sep4.setBackground( GUIResource.getInstance().getColorWhite() ); FormData fdSep4 = new FormData(); fdSep4.left = new FormAttachment( 0, 0 ); fdSep4.right = new FormAttachment( 100, 0 ); fdSep4.top = new FormAttachment( treeTb, 5 ); sep4.setLayoutData( fdSep4 ); }
Example 13
Source File: ChipsSnippet.java From nebula with Eclipse Public License 2.0 | 4 votes |
private static void createCloseChipsArea() { final Label lbl = new Label(shell, SWT.CENTER); lbl.setText("Close chips (Eclipse Fundation Members)"); lbl.setBackground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE)); final Composite cmp = new Composite(shell, SWT.NONE); cmp.setLayoutData(new GridData(GridData.CENTER, GridData.FILL, false, false)); cmp.setLayout(new GridLayout(4, false)); cmp.setBackground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE)); final Color bgColor = SWTGraphicUtil.getColorSafely(224, 224, 244); final Chips chip1 = new Chips(cmp, SWT.CLOSE); chip1.setForeground(shell.getDisplay().getSystemColor(SWT.COLOR_BLACK)); chip1.setChipsBackground(bgColor); chip1.setBackground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE)); chip1.setText("IBM"); final Chips chip2 = new Chips(cmp, SWT.CLOSE); chip2.setForeground(shell.getDisplay().getSystemColor(SWT.COLOR_BLACK)); chip2.setChipsBackground(bgColor); chip2.setBackground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE)); chip2.setText("Red Hat"); final Chips chip3 = new Chips(cmp, SWT.CLOSE); chip3.setForeground(shell.getDisplay().getSystemColor(SWT.COLOR_BLACK)); chip3.setChipsBackground(bgColor); chip3.setBackground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE)); chip3.setText("Remain Software"); final Chips chip4 = new Chips(cmp, SWT.CLOSE); chip4.setForeground(shell.getDisplay().getSystemColor(SWT.COLOR_BLACK)); chip4.setChipsBackground(bgColor); chip4.setBackground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE)); chip4.setText("Vogella"); final CloseListener closeListener = event -> { final Chips chip = (Chips) event.widget; System.out.println("Closed on " + chip.getText()); chip.dispose(); cmp.layout(true); }; chip1.addCloseListener(closeListener); chip2.addCloseListener(closeListener); chip3.addCloseListener(closeListener); chip4.addCloseListener(closeListener); }
Example 14
Source File: PasswordRevealerSnippet.java From nebula with Eclipse Public License 2.0 | 4 votes |
public static void main(final String[] args) { final Display display = new Display(); final Shell shell = new Shell(display); shell.setLayout(new GridLayout(1, false)); final Color white = display.getSystemColor(SWT.COLOR_WHITE); shell.setBackground(white); shell.setText("Password Revealer Snippet"); final Image image = new Image(display, PasswordRevealerSnippet.class.getResourceAsStream("eye.png")); final Image clickImage = new Image(display, PasswordRevealerSnippet.class.getResourceAsStream("eye-slash.png")); shell.addListener(SWT.Dispose, e -> { image.dispose(); clickImage.dispose(); }); final Label lbl1 = new Label(shell, SWT.NONE); lbl1.setText("Password Revealer:"); final GridData gdLabel1 = new GridData(GridData.BEGINNING, GridData.CENTER, true, false); gdLabel1.widthHint = 150; lbl1.setBackground(white); lbl1.setLayoutData(gdLabel1); final PasswordRevealer revealer = new PasswordRevealer(shell, SWT.NONE); final GridData gd = new GridData(GridData.FILL, GridData.CENTER, true, false); gd.widthHint = 250; revealer.setLayoutData(gd); revealer.setBackground(white); new Label(shell, SWT.NONE); final Label lbl2 = new Label(shell, SWT.NONE); lbl2.setText("Password Revealer with other icon:"); final GridData gdLabel2 = new GridData(GridData.FILL, GridData.CENTER, true, false); gdLabel2.widthHint = 150; lbl2.setBackground(white); lbl2.setLayoutData(gdLabel2); final PasswordRevealer revealer2 = new PasswordRevealer(shell, SWT.NONE); final GridData gd2 = new GridData(GridData.FILL, GridData.CENTER, true, false); gd2.widthHint = 250; revealer2.setLayoutData(gd2); revealer2.setBackground(white); revealer2.setImage(image); revealer2.setClickImage(clickImage); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
Example 15
Source File: BadgedLabelSnippet.java From nebula with Eclipse Public License 2.0 | 4 votes |
private static void createButtons(final String text, int color, int location) { final Label label = new Label(shell, SWT.NONE); label.setBackground(label.getDisplay().getSystemColor(SWT.COLOR_WHITE)); String locationText; if (location == (SWT.BOTTOM | SWT.LEFT)) { locationText = "Bottom left"; } else if (location == (SWT.BOTTOM | SWT.RIGHT)) { locationText = "Bottom right"; } else if (location == (SWT.TOP | SWT.LEFT)) { locationText = "Top left"; } else { locationText = "Top right"; } label.setText(text + " " + locationText); label.setLayoutData(new GridData(GridData.END, GridData.CENTER, false, false)); final BadgedLabel button1 = new BadgedLabel(shell, location); button1.setText("Notification"); final GridData gd = new GridData(GridData.FILL, GridData.CENTER, false, false); gd.widthHint = 200; gd.heightHint = 100; button1.setLayoutData(gd); button1.setBadgeValue("1"); button1.setPredefinedColor(color); button1.setBackground(label.getDisplay().getSystemColor(SWT.COLOR_WHITE)); final BadgedLabel button2 = new BadgedLabel(shell, location); button2.setText("Text & image"); button2.setImage(icon); button2.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, false, false)); button2.setPredefinedColor(color); button2.setBadgeValue("2"); button2.setBackground(label.getDisplay().getSystemColor(SWT.COLOR_WHITE)); final BadgedLabel button3 = new BadgedLabel(shell, location); button3.setImage(icon); button3.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, false, false)); button3.setPredefinedColor(color); button3.setBadgeValue("99+"); button3.setBackground(label.getDisplay().getSystemColor(SWT.COLOR_WHITE)); final BadgedLabel button4 = new BadgedLabel(shell, location); button4.setText("Disabled"); button4.setEnabled(false); button4.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, false, false)); button4.setPredefinedColor(color); button4.setBadgeValue("New"); button4.setBackground(label.getDisplay().getSystemColor(SWT.COLOR_WHITE)); }
Example 16
Source File: SpinnerTime.java From birt with Eclipse Public License 1.0 | 4 votes |
private void initComponents( ) { hour = new SpinnerTimeText( this, SWT.NONE, 24, IPropertyEventConstants.HOUR_CHANGE_EVENT ); firstLabel = new Label( this, SWT.NONE ); min = new SpinnerTimeText( this, SWT.NONE, 60, IPropertyEventConstants.MIN_CHANGE_EVENT ); lastLabel = new Label( this, SWT.NONE ); sec = new SpinnerTimeText( this, SWT.NONE, 60, IPropertyEventConstants.SECOND_CHANGE_EVENT ); // Font font = new Font( Display.getCurrent( ), "Dialog", 10, SWT.BOLD // ); //$NON-NLS-1$ Font font = FontManager.getFont( "Dialog", 10, SWT.BOLD ); //$NON-NLS-1$ firstLabel.setBackground( Display.getCurrent( ) .getSystemColor( SWT.COLOR_WHITE ) ); lastLabel.setBackground( Display.getCurrent( ) .getSystemColor( SWT.COLOR_WHITE ) ); firstLabel.setFont( font ); lastLabel.setFont( font ); firstLabel.setForeground( Display.getCurrent( ) .getSystemColor( SWT.COLOR_BLACK ) ); lastLabel.setForeground( Display.getCurrent( ) .getSystemColor( SWT.COLOR_BLACK ) ); firstLabel.setText( ":" ); //$NON-NLS-1$ lastLabel.setText( ":" ); //$NON-NLS-1$ up = new Button( this, SWT.ARROW | SWT.UP ); down = new Button( this, SWT.ARROW | SWT.DOWN ); label = new Label( this, SWT.NONE ); label.setBackground( Display.getCurrent( ) .getSystemColor( SWT.COLOR_WHITE ) ); //added by gao 2004.07.08 //font.dispose( ); }
Example 17
Source File: BasePanel.java From nebula with Eclipse Public License 2.0 | 4 votes |
protected void createLeftLabel(Composite composite, String text) { final Label lbl = new Label(composite, SWT.NONE); lbl.setText(text); lbl.setBackground(composite.getDisplay().getSystemColor(SWT.COLOR_WHITE)); lbl.setLayoutData(new GridData(GridData.END, GridData.CENTER, false, false)); }
Example 18
Source File: DecoratedStringChooser.java From elexis-3-core with Eclipse Public License 1.0 | 4 votes |
public DecoratedStringChooser(Composite parent, final Settings cfg, final DecoratedString[] strings){ super(parent, SWT.BORDER); int num = strings.length; int typRows = ((int) Math.sqrt(num)); int typCols = typRows + (num - (typRows * typRows)); if (typCols < 4) { typCols = 4; } setLayout(new GridLayout(typCols, true)); Label expl = new Label(this, SWT.WRAP); expl.setText(Messages.DecoratedStringChooser_howToChange); //$NON-NLS-1$ expl.setLayoutData(SWTHelper.getFillGridData(typCols, false, 1, false)); for (int i = 0; i < num; i++) { Label lab = new Label(this, SWT.NONE); lab.setText(strings[i].getText()); lab.setData(strings[i].getValue()); String coldesc; if(strings[i].getValue() != null) { coldesc = cfg.get(strings[i].getValue(), "FFFFFF"); //$NON-NLS-1$ } else { coldesc = cfg.get(strings[i].getText(), "FFFFFF"); //$NON-NLS-1$ } Color background = UiDesk.getColorFromRGB(coldesc); lab.setBackground(background); GridData gd = new GridData(GridData.FILL_BOTH); lab.setLayoutData(gd); lab.addMouseListener(new MouseAdapter() { @Override public void mouseDoubleClick(MouseEvent e){ ColorDialog cd = new ColorDialog(getShell()); Label l = (Label) e.getSource(); RGB selected = cd.open(); if (selected != null) { String symbolic = UiDesk.createColor(selected); l.setBackground(UiDesk.getColorFromRGB(symbolic)); if(l.getData() != null) { cfg.set((String) l.getData(), symbolic); } else { cfg.set(l.getText(), symbolic); } } } }); } }
Example 19
Source File: LinkingMatrix.java From olca-app with Mozilla Public License 2.0 | 4 votes |
private Label filler(Composite parent) { Label f = new Label(parent, SWT.NONE); f.setBackground(Colors.white()); return f; }
Example 20
Source File: DialogCellEditor.java From olca-app with Mozilla Public License 2.0 | 3 votes |
/** * Creates the controls used to show the value of this cell editor. * <p> * The default implementation of this framework method creates a label * widget, using the same font and background color as the parent control. * </p> * <p> * Subclasses may reimplement. If you reimplement this method, you should * also reimplement <code>updateContents</code>. * </p> * * @param cell * the control for this cell editor * @return the underlying control */ protected Control createContents(Composite cell) { defaultLabel = new Label(cell, SWT.LEFT); defaultLabel.setFont(cell.getFont()); defaultLabel.setBackground(cell.getBackground()); return defaultLabel; }