Java Code Examples for org.eclipse.swt.widgets.Label#setFont()

The following examples show how to use org.eclipse.swt.widgets.Label#setFont() . 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: NewProject.java    From AndroidRobot with Apache License 2.0 6 votes vote down vote up
/**
 * Create contents of the dialog.
 */
private void createContents() {
    display = getParent().getDisplay();
    shell = new Shell(getParent(), getStyle());
    shell.setSize(450, 300);
    shell.setText(getText());
    shell
        .setImage(new Image(display, ClassLoader.getSystemResourceAsStream("icons/title.png")));
    shell.setLayout(new GridLayout(1, false));

    Composite composite1 = new Composite(shell, SWT.NONE);
    composite1.setLayoutData(new GridData(435, 50));
    composite1.setLayout(new GridLayout(1, false));

    Label lbNewScript = new Label(composite1, SWT.CENTER);
    lbNewScript.setText("新建项目框");
    lbNewScript.setFont(new Font(display, "宋体", 12, SWT.BOLD));

    lblError = new Label(composite1, SWT.NONE);
    GridData gd_lblError = new GridData(SWT.LEFT, SWT.CENTER, false, false, 3, 1);
    gd_lblError.widthHint = 207;
    lblError.setLayoutData(gd_lblError);
    lblError.setText("");

}
 
Example 2
Source File: TypeSelectionComponent.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private Control createHeader(Composite parent, Font font, String message) {
	Composite header= new Composite(parent, SWT.NONE);
	GridLayout layout= new GridLayout();
	layout.numColumns= 2;
	layout.marginWidth= 0; layout.marginHeight= 0;
	header.setLayout(layout);
	header.setFont(font);
	Label label= new Label(header, SWT.NONE);
	label.setText(message);
	label.setFont(font);
	label.addTraverseListener(new TraverseListener() {
		public void keyTraversed(TraverseEvent e) {
			if (e.detail == SWT.TRAVERSE_MNEMONIC && e.doit) {
				e.detail= SWT.TRAVERSE_NONE;
				fFilter.setFocus();
			}
		}
	});
	GridData gd= new GridData(GridData.FILL_HORIZONTAL);
	label.setLayoutData(gd);
	
	createViewMenu(header);
	return header;
}
 
Example 3
Source File: TaskSelectData.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
private void createPreviewArea( Composite parent )
{
	Composite cmpPreview = ChartUIUtil.createCompositeWrapper( parent );
	{
		GridData gridData = new GridData( GridData.FILL_BOTH );
		gridData.widthHint = CENTER_WIDTH_HINT;
		gridData.heightHint = 200;
		cmpPreview.setLayoutData( gridData );
	}

	Label label = new Label( cmpPreview, SWT.NONE );
	{
		label.setFont( JFaceResources.getBannerFont( ) );
		label.setText( Messages.getString( "TaskSelectData.Label.ChartPreview" ) ); //$NON-NLS-1$
	}

	previewCanvas = new Canvas( cmpPreview, SWT.BORDER );
	{
		GridData gd = new GridData( GridData.FILL_BOTH );
		previewCanvas.setLayoutData( gd );
		previewCanvas.setBackground( Display.getDefault( )
				.getSystemColor( SWT.COLOR_WIDGET_BACKGROUND ) );
	}
}
 
Example 4
Source File: ProjectFileDialog.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
protected Label createMessageArea( Composite composite )
{
	Composite infoContent = new Composite( composite, SWT.NONE );

	GridData data = new GridData( );
	data.grabExcessVerticalSpace = false;
	data.grabExcessHorizontalSpace = true;
	data.horizontalAlignment = GridData.FILL;
	data.verticalAlignment = GridData.BEGINNING;
	infoContent.setLayoutData( data );

	GridLayout layout = new GridLayout( );
	layout.marginTop = layout.marginBottom = layout.marginLeft = layout.marginRight = layout.marginHeight = layout.marginWidth = 0;
	layout.numColumns = 2;
	infoContent.setLayout( layout );

	Label label = new Label( infoContent, SWT.NONE );
	if ( getMessage( ) != null )
	{
		label.setText( getMessage( ) );
	}
	label.setFont( composite.getFont( ) );
	label.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );

	createViewMenu( infoContent );

	return label;
}
 
Example 5
Source File: DirectorySelectionDialog.java    From MergeProcessor with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected Control createDialogArea(Composite parent) {
	final Composite dialogComposite = (Composite) super.createDialogArea(parent);

	final Composite composite = new Composite(dialogComposite, SWT.NONE);
	composite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
	composite.setLayout(new GridLayout(2, false));

	if (StringUtils.isNotEmpty(mergeFrom) && StringUtils.isNotEmpty(mergeTo)) {
		final Composite compMergeFromTo = new Composite(composite, SWT.NONE);
		compMergeFromTo.setLayout(new RowLayout(SWT.HORIZONTAL));
		compMergeFromTo.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 2, 1));

		new Label(compMergeFromTo, SWT.NONE).setText(Messages.DirectorySelectionDialog_mergeFrom);

		final Label labelFrom = new Label(compMergeFromTo, SWT.NONE);
		labelFrom.setFont(JFaceResources.getFontRegistry().getBold(""));
		labelFrom.setText(mergeFrom);

		new Label(compMergeFromTo, SWT.NONE).setText(Messages.DirectorySelectionDialog_mergeTo);

		final Label labelTo = new Label(compMergeFromTo, SWT.NONE);
		labelTo.setFont(JFaceResources.getFontRegistry().getBold(""));
		labelTo.setText(mergeTo);
	}

	textRepository = new Text(composite, SWT.BORDER);
	textRepository.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
	if (selectedPath != null) {
		textRepository.setText(selectedPath.toString());
	}
	textRepository.addModifyListener(e -> setErrorMessage(null));

	final Button buttonBrowseRepository = new Button(composite, SWT.NONE);
	buttonBrowseRepository.setText(Messages.DirectorySelectionDialog_browse);
	buttonBrowseRepository.addListener(SWT.Selection, e -> openDirectoryDialog());

	return dialogComposite;
}
 
Example 6
Source File: JSEditor.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
private void initScriptLabel( Composite parent )
{
	Label lblScript = new Label( parent, SWT.NONE );
	lblScript.setText( Messages.getString( "JSEditor.Label.Script" ) ); //$NON-NLS-1$
	final FontData fd = lblScript.getFont( ).getFontData( )[0];
	Font labelFont = FontManager.getFont( fd.getName( ),
			fd.getHeight( ),
			SWT.BOLD );
	lblScript.setFont( labelFont );
	GridData layoutData = new GridData( SWT.BEGINNING );
	lblScript.setLayoutData( layoutData );

}
 
Example 7
Source File: AbstractFormatterSelectionBlock.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
protected static Label createLabel(Composite composite, String text, int numColumns, boolean wrap)
{
	final GridData gd = new GridData(GridData.FILL_HORIZONTAL);
	gd.horizontalSpan = numColumns;
	if (wrap)
	{
		gd.heightHint = new PixelConverter(composite).convertHeightInCharsToPixels(2);
	}

	final Label label = new Label(composite, wrap ? SWT.WRAP : SWT.NONE);
	label.setFont(composite.getFont());
	label.setText(text);
	label.setLayoutData(gd);
	return label;
}
 
Example 8
Source File: DialogLogoCmp.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
public void init(){
	GridDataFactory.fillDefaults().grab(true, false).hint(SWT.DEFAULT, 70).applyTo(this);
	GridLayoutFactory.fillDefaults().numColumns(2).margins(0, 0).applyTo(this);
	Color textBgColor = Display.getCurrent().getSystemColor(SWT.COLOR_WHITE);
	this.setBackground(textBgColor);
	
	Composite leftLogoCmp = new Composite(this, SWT.NONE);
	GridDataFactory.fillDefaults().grab(true, true).applyTo(leftLogoCmp);
	leftLogoCmp.setBackground(textBgColor);
	GridLayoutFactory.fillDefaults().numColumns(1).extendedMargins(10, 0, 8, 0).applyTo(leftLogoCmp);
	
	titileLbl = new Label(leftLogoCmp, SWT.NONE);
	titileLbl.setText(title == null ? "" : title);
	titileLbl.setBackground(textBgColor);
	titileLbl.setFont(JFaceResources.getBannerFont());
	
	tipTxt = new Label(leftLogoCmp, SWT.WRAP);
	tipTxt.setText(message == null ? "" : message);
	GridDataFactory.fillDefaults().grab(true, true).indent(8, 4).applyTo(tipTxt);
	tipTxt.setBackground(textBgColor);
	tipTxt.setToolTipText(message == null ? "" : message);
	tipTxt.setFont(JFaceResources.getDialogFont());
	
	rightLogoCmp = new Composite(this, SWT.NONE);
	rightLogoCmp.setBackground(textBgColor);
	GridDataFactory.swtDefaults().hint(100, SWT.DEFAULT).grab(false, true).applyTo(rightLogoCmp);
	if(logo!=null){
		rightLogoCmp.setBackgroundImage(logo);			
	}
}
 
Example 9
Source File: SelectDataWizardPage.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private void createDataTypeSelectionRadioButtons(Composite parent) {
    Label dataLabel = new Label(parent, SWT.NONE);
    dataLabel.setLayoutData(GridDataFactory.fillDefaults().create());
    dataLabel.setText(Messages.data);
    dataLabel.setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.DEFAULT_FONT));

    Composite buttonComposite = new Composite(parent, SWT.NONE);
    buttonComposite.setLayoutData(GridDataFactory.fillDefaults().span(2, 1).grab(true, false).create());
    buttonComposite.setLayout(GridLayoutFactory.fillDefaults().numColumns(2).create());

    businessVariableButton = new Button(buttonComposite, SWT.RADIO);
    businessVariableButton.setText(Messages.businessVariable);
    documentButton = new Button(buttonComposite, SWT.RADIO);
    documentButton.setText(Messages.document);
    selectionTypeObservable = new SelectObservableValue<>(Boolean.class);
    selectionTypeObservable.addOption(Boolean.TRUE, WidgetProperties.selection().observe(businessVariableButton));
    selectionTypeObservable.addOption(Boolean.FALSE, WidgetProperties.selection().observe(documentButton));

    if (availableBusinessData.isEmpty()) {
        setBusinessDataTypeSelected(false);
        businessVariableButton.setEnabled(false);
    }
    if (availableDocuments.isEmpty()) {
        setBusinessDataTypeSelected(true);
        documentButton.setEnabled(false);
    }
}
 
Example 10
Source File: RenameExperimentDialog.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
private void createNewExperimentNameGroup(Composite parent) {
    Font font = parent.getFont();
    Composite folderGroup = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.numColumns = 2;
    folderGroup.setLayout(layout);
    folderGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    String name = fExperiment.getName();

    // New experiment name label
    Label newExperimentLabel = new Label(folderGroup, SWT.NONE);
    newExperimentLabel.setFont(font);
    newExperimentLabel.setText(Messages.RenameExperimentDialog_ExperimentNewName);

    // New experiment name entry field
    fNewExperimentName = new Text(folderGroup, SWT.BORDER);
    GridData data = new GridData(GridData.FILL_HORIZONTAL);
    data.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH;
    fNewExperimentName.setLayoutData(data);
    fNewExperimentName.setFont(font);
    fNewExperimentName.setFocus();
    fNewExperimentName.setText(name);
    fNewExperimentName.setSelection(0, name.length());

    fNewExperimentName.addListener(SWT.Modify, event -> validateNewExperimentName());
}
 
Example 11
Source File: SWTFactory.java    From xds-ide with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Creates a wrapping label
 * @param parent the parent composite to add this label to
 * @param text the text to be displayed in the label
 * @param hspan the horizontal span that label should take up in the parent composite
 * @param wrapwidth the width hint that the label should wrap at
 * @return a new label that wraps at a specified width
 */
public static Label createWrapLabel(Composite parent, String text, int hspan, int wrapwidth) {
	Label l = new Label(parent, SWT.NONE | SWT.WRAP);
	l.setFont(parent.getFont());
	l.setText(text);
	GridData gd = new GridData(GridData.FILL_HORIZONTAL);
	gd.horizontalSpan = hspan;
	gd.widthHint = wrapwidth;
	l.setLayoutData(gd);
	return l;
}
 
Example 12
Source File: JarManifestWizardPage.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Creates a new label with a bold font.
 *
 * @param parent the parent control
 * @param text the label text
 * @param bold bold or not
 * @return the new label control
 */
protected Label createLabel(Composite parent, String text, boolean bold) {
	Label label= new Label(parent, SWT.NONE);
	if (bold)
		label.setFont(JFaceResources.getBannerFont());
	label.setText(text);
	GridData data= new GridData();
	data.verticalAlignment= GridData.FILL;
	data.horizontalAlignment= GridData.FILL;
	label.setLayoutData(data);
	return label;
}
 
Example 13
Source File: SWTFactory.java    From tlaplus with MIT License 5 votes vote down vote up
/**
 * Creates a wrapping label
 * 
 * @param parent the parent composite to add this label to
 * @param text the text to be displayed in the label
 * @param hspan the horizontal span that label should take up in the parent composite
 * @return a new label that wraps at a specified width
 */
public static Label createWrapLabel(Composite parent, String text, int hspan) {
	Label l = new Label(parent, SWT.NONE | SWT.WRAP);
	l.setFont(parent.getFont());
	if(text != null) {
		l.setText(text);
	}
	GridData gd = new GridData(GridData.BEGINNING);
	gd.horizontalSpan = hspan;
	l.setLayoutData(gd);
	return l;
}
 
Example 14
Source File: ComponentTitledSeparator.java    From arx with Apache License 2.0 5 votes vote down vote up
/**
 * @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 15
Source File: Clock.java    From statecharts with Eclipse Public License 1.0 5 votes vote down vote up
protected void createContents() {
	setLayout(new GridLayout(2, false));
	timeIconLabel = new Label(this, SWT.NONE);
	timeIconLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false));
	timeIconLabel.setImage(SimulationImages.SIMULATION_CLOCK.image());
	timeIconLabel.setToolTipText("Displays the duration since the simulation is running");
	timeLabel = new Label(this, SWT.NONE);
	timeLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false));
	timeLabel.setFont(font);
	timeLabel.setToolTipText("Simulation Time");
}
 
Example 16
Source File: ApplicationOverviewEditorPart.java    From codewind-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
public StringEntry(Composite composite, String name) {
	label = new Label(composite, SWT.NONE);
	label.setFont(boldFont);
	label.setText(name);
	label.setLayoutData(new GridData(GridData.BEGINNING, GridData.BEGINNING, false, false));
       
       text = new Text(composite, SWT.WRAP | SWT.MULTI | SWT.READ_ONLY);
       text.setData(FormToolkit.KEY_DRAW_BORDER, Boolean.FALSE);
       text.setLayoutData(new GridData(GridData.BEGINNING, GridData.BEGINNING, true, false));
       IDEUtil.paintBackgroundToMatch(text, composite);
}
 
Example 17
Source File: SWTFactory.java    From tlaplus with MIT License 5 votes vote down vote up
/**
 * Creates a new label widget
 * 
 * @param parent the parent composite to add this label widget to
 * @param text the text for the label
 * @param hspan the horizontal span to take up in the parent composite
 * @return the new label
 */
public static Label createLabel(Composite parent, String text, int hspan) {
	Label l = new Label(parent, SWT.NONE);
	l.setFont(parent.getFont());
	if(text != null) {
		l.setText(text);
	}
	GridData gd = new GridData(GridData.FILL_HORIZONTAL);
	gd.horizontalSpan = hspan;
	gd.grabExcessHorizontalSpace = false;
	l.setLayoutData(gd);
	return l;
}
 
Example 18
Source File: SourceActionDialog.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Returns a composite containing the label created at the top of the dialog. Returns null if there is the
 * message for the label is null.
 * @param composite the parent composite
 * @return the label
 */
@Override
protected Label createMessageArea(Composite composite) {
	if (getMessage() != null) {
		Label label = new Label(composite,SWT.NONE);
		label.setText(getMessage());
		label.setFont(composite.getFont());
		return label;
	}
	return null;
}
 
Example 19
Source File: FolderSelectionGroup.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Create group
 * 
 * @param parent
 */
public void create( Composite parent )
{
	// get font
	Font font = parent.getFont( );

	// label control
	Label label = new Label( parent, SWT.LEFT );
	label.setFont( font );
	label.setText( this.labelText );

	Composite composite = new Composite( parent, SWT.NULL );
	GridLayout layout = new GridLayout( );
	layout.marginWidth = 0;
	layout.marginHeight = 0;
	layout.numColumns = 2;
	composite.setLayout( layout );

	GridData data = new GridData( GridData.FILL_HORIZONTAL );
	composite.setLayoutData( data );

	// text control
	text = new Text( composite, SWT.BORDER );
	text.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
	text.setFont( font );
	text.setText( this.textValue );
	text.addVerifyListener( new VerifyListener( ) {

		public void verifyText( VerifyEvent e )
		{
			e.doit = e.text.indexOf( DELIMITER ) < 0;
		}
	} );

	// directory selection button
	button = new Button( composite, SWT.PUSH );
	button.setFont( font );
	button.setText( this.buttonText );
	button.addSelectionListener( new SelectionAdapter( ) {

		public void widgetSelected( SelectionEvent event )
		{
			dialog = new DirectoryDialog( PlatformUI.getWorkbench( )
					.getDisplay( ).getActiveShell( ) );

			dialog.setText( dialogTitle );
			dialog.setMessage( dialogMessage );
			dialog.setFilterPath( dialogFilterPath );
			String folderName = dialog.open( );
			if ( folderName == null )
			{
				return;
			}
			text.setText( folderName );
		}
	} );
}
 
Example 20
Source File: NewFolderDialogOfHs.java    From translationstudio8 with GNU General Public License v2.0 votes vote down vote up
/**
		 * Creates the folder name specification controls.
		 *
		 * @param parent the parent composite
		 */
		private void createFolderNameGroup(Composite parent) {
			Font font = parent.getFont();
			// project specification group
			Composite folderGroup = new Composite(parent, SWT.NONE);
			GridLayout layout = new GridLayout();
			layout.numColumns = 2;
			folderGroup.setLayout(layout);
			folderGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

			// new folder label
			Label folderLabel = new Label(folderGroup, SWT.NONE);
			folderLabel.setFont(font);
			folderLabel.setText(IDEWorkbenchMessages.NewFolderDialog_nameLabel);

			// new folder name entry field
			folderNameField = new Text(folderGroup, SWT.BORDER);
			GridData data = new GridData(GridData.FILL_HORIZONTAL);
			data.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH;
			folderNameField.setLayoutData(data);
			folderNameField.setFont(font);
			folderNameField.addListener(SWT.Modify, new Listener() {
				public void handleEvent(Event event) {
					validateLinkedResource();
				}
			});
		}