org.eclipse.swt.widgets.Button#setFont ( )源码实例Demo

下面列出了org.eclipse.swt.widgets.Button#setFont ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: tmxeditor8   文件: WizardExportResourcesPage2.java
/**
 * Creates a new button with the given id.
 * <p>
 * The <code>Dialog</code> implementation of this framework method creates a standard push button, registers for
 * selection events including button presses and registers default buttons with its shell. The button id is stored
 * as the buttons client data. Note that the parent's layout is assumed to be a GridLayout and the number of columns
 * in this layout is incremented. Subclasses may override.
 * </p>
 * @param parent
 *            the parent composite
 * @param id
 *            the id of the button (see <code>IDialogConstants.*_ID</code> constants for standard dialog button ids)
 * @param label
 *            the label from the button
 * @param defaultButton
 *            <code>true</code> if the button is to be the default button, and <code>false</code> otherwise
 */
protected Button createButton(Composite parent, int id, String label, boolean defaultButton) {
	// increment the number of columns in the button bar
	((GridLayout) parent.getLayout()).numColumns++;

	Button button = new Button(parent, SWT.PUSH);

	GridData buttonData = new GridData(GridData.FILL_HORIZONTAL);
	button.setLayoutData(buttonData);

	button.setData(new Integer(id));
	button.setText(label);
	button.setFont(parent.getFont());

	if (defaultButton) {
		Shell shell = parent.getShell();
		if (shell != null) {
			shell.setDefaultButton(button);
		}
		button.setFocus();
	}
	button.setFont(parent.getFont());
	setButtonLayoutData(button);
	return button;
}
 
源代码2 项目: birt   文件: ScriptSWTFactory.java
/**
 * Create the push button
 * 
 * @param parent
 * @param label
 * @param image
 * @return
 */
public static Button createPushButton( Composite parent, String label,
		Image image )
{
	Button button = new Button( parent, SWT.PUSH );
	button.setFont( parent.getFont( ) );
	if ( image != null )
	{
		button.setImage( image );
	}
	if ( label != null )
	{
		button.setText( label );
	}

	GridData gd = new GridData( );
	button.setLayoutData( gd );
	setButtonDimensionHint( button );
	return button;
}
 
@Override
protected Control createCustomArea(final Composite parent) {

	final Composite composite= new Composite(parent, SWT.NONE);
	composite.setLayout(new GridLayout());

	fRemoveBuildPathAndFolder= new Button(composite, SWT.RADIO);
	fRemoveBuildPathAndFolder.addSelectionListener(selectionListener);

	fRemoveBuildPathAndFolder.setText(NewWizardMessages.ClasspathModifierQueries_delete_linked_folder);
	fRemoveBuildPathAndFolder.setFont(parent.getFont());

	fRemoveBuildPath= new Button(composite, SWT.RADIO);
	fRemoveBuildPath.addSelectionListener(selectionListener);

	fRemoveBuildPath.setText(NewWizardMessages.ClasspathModifierQueries_do_not_delete_linked_folder);
	fRemoveBuildPath.setFont(parent.getFont());

	fRemoveBuildPathAndFolder.setSelection(fRemoveStatus == IRemoveLinkedFolderQuery.REMOVE_BUILD_PATH_AND_FOLDER);
	fRemoveBuildPath.setSelection(fRemoveStatus == IRemoveLinkedFolderQuery.REMOVE_BUILD_PATH);

	return composite;
}
 
源代码4 项目: EasyShell   文件: CommandPage.java
private void createCopyButton(Font font, GridData gridData, Composite groupComponent) {
    addCopyButton = new Button(groupComponent, SWT.PUSH);
    addCopyButton.setText(Activator.getResourceString("easyshell.command.page.button.text.copy"));
    addCopyButton.setToolTipText(Activator.getResourceString("easyshell.command.page.button.tooltip.copy"));
    addCopyButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent event) {
            addCopyDialog();
        }
    });
    addCopyButton.setLayoutData(gridData);
    addCopyButton.setFont(font);
    setButtonLayoutData(addCopyButton);
}
 
源代码5 项目: cppcheclipse   文件: TableEditor.java
/**
 * Helper method to create a push button.
 * 
 * @param parent
 *            the parent control
 * @param key
 *            the resource name used to supply the button's label text
 * @return Button
 */
protected Button createPushButton(Composite parent, String key,
		SelectionListener listener) {
	Button button = new Button(parent, SWT.PUSH);
	button.setText(JFaceResources.getString(key));
	button.setFont(parent.getFont());
	GridData data = new GridData(GridData.FILL_HORIZONTAL);
	int widthHint = convertHorizontalDLUsToPixels(button,
			IDialogConstants.BUTTON_WIDTH);
	data.widthHint = Math.max(widthHint,
			button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x);
	button.setLayoutData(data);
	button.addSelectionListener(listener);
	return button;
}
 
源代码6 项目: Pydev   文件: PythonBreakpointPage.java
/**
 * Creates a fully configured check button with the given text.
 * @param parent the parent composite
 * @param text the label of the returned check button
 * @return a fully configured check button
 */
protected Button createCheckButton(Composite parent, String text) {
    Button button = new Button(parent, SWT.CHECK | SWT.LEFT);
    button.setText(text);
    button.setFont(parent.getFont());
    button.setLayoutData(new GridData());
    return button;
}
 
private static Button createButton(Composite composite, String text, final int style) {
	final Button button= new Button(composite, SWT.PUSH);
	button.setFont(composite.getFont());
	button.setText(text);

	final GridData gd= new GridData(style);
	gd.widthHint= SWTUtil.getButtonWidthHint(button);
	button.setLayoutData(gd);
	return button;
}
 
源代码8 项目: xtext-eclipse   文件: OptionsConfigurationBlock.java
protected Button addCheckboxWithData(Composite parent, String label, ControlData data, GridData gd) {
	Button checkBox = new Button(parent, SWT.CHECK);
	checkBox.setFont(JFaceResources.getDialogFont());
	checkBox.setText(label);
	checkBox.setData(data);
	checkBox.setLayoutData(gd);
	checkBox.addSelectionListener(getSelectionListener());
	makeScrollableCompositeAware(checkBox);
	updateCheckBox(checkBox);
	checkBoxes.add(checkBox);
	return checkBox;
}
 
源代码9 项目: APICloud-Studio   文件: SWTUtil.java
/**
 * Returns a width hint for a button control.
 */
public static int getButtonWidthHint(Button button)
{
	button.setFont(JFaceResources.getDialogFont());
	PixelConverter converter = new PixelConverter(button);
	int widthHint = converter.convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);
	return Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x);
}
 
源代码10 项目: EasyShell   文件: MenuPage.java
private void createNewButton(Font font, GridData gridData, Composite groupComponent) {
    addNewButton = new Button(groupComponent, SWT.PUSH);
    addNewButton.setText(Activator.getResourceString("easyshell.menu.page.button.text.new"));
    addNewButton.setToolTipText(Activator.getResourceString("easyshell.menu.page.button.tooltip.new"));
    addNewButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent event) {
            addNewDialog();
        }
    });
    addNewButton.setLayoutData(gridData);
    addNewButton.setFont(font);
    setButtonLayoutData(addNewButton);
}
 
源代码11 项目: APICloud-Studio   文件: SWTUtil.java
/**
 * Creates and returns a new radio button with the given label.
 * 
 * @param parent
 *            parent control
 * @param label
 *            button label or <code>null</code>
 * @return a new radio button
 */
public static Button createRadioButton(Composite parent, String label)
{
	Button button = new Button(parent, SWT.RADIO);
	button.setFont(parent.getFont());
	if (label != null)
	{
		button.setText(label);
	}
	GridData gd = new GridData();
	button.setLayoutData(gd);
	SWTUtil.setButtonDimensionHint(button);
	return button;
}
 
源代码12 项目: birt   文件: TreeListDialogField.java
protected Button createButton(Composite parent, String label, SelectionListener listener) {
	Button button= new Button(parent, SWT.PUSH);
	button.setFont(parent.getFont());
	button.setText(label);
	button.addSelectionListener(listener);
	GridData gd= new GridData();
	gd.horizontalAlignment= GridData.FILL;
	gd.grabExcessHorizontalSpace= true;
	gd.verticalAlignment= GridData.BEGINNING;
	gd.widthHint= getButtonWidthHint(button);

	button.setLayoutData(gd);
	return button;
}
 
源代码13 项目: Pydev   文件: AbstractInterpreterEditor.java
/**
 * Helper method to create a push button.
 *
 * @param parent the parent control
 * @param key the resource name used to supply the button's label text
 * @param listenerToAdd
 * @return Button
 */
/*default*/public static Button createBt(Composite parent, String key, SelectionListener listenerToAdd) {
    Button button = new Button(parent, SWT.PUSH);
    button.setText(JFaceResources.getString(key));
    button.setFont(parent.getFont());
    GridData data = new GridData(GridData.FILL_HORIZONTAL);
    //        data.heightHint = convertVerticalDLUsToPixels(button, IDialogConstants.BUTTON_HEIGHT);
    int widthHint = convertHorizontalDLUsToPixelsStatic(button, IDialogConstants.BUTTON_WIDTH);
    data.widthHint = Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x);
    button.setLayoutData(data);
    button.addSelectionListener(listenerToAdd);
    return button;
}
 
/**
 * Create the button for checking if we should ask if we are going to overwrite existing files.
 * @param optionsGroup
 * @param font
 */
protected void createOverwriteExisting(Group optionsGroup, Font font) {
	// overwrite... checkbox
	overwriteExistingFilesCheckbox = new Button(optionsGroup, SWT.CHECK | SWT.LEFT);
	overwriteExistingFilesCheckbox.setText(DataTransferMessages.ExportFile_overwriteExisting);
	overwriteExistingFilesCheckbox.setFont(font);
}
 
/**
 * Create the export destination specification widgets
 * @param parent
 *            org.eclipse.swt.widgets.Composite
 */
protected void createDestinationGroup(Composite parent) {

	Font font = parent.getFont();
	// destination specification group
	Composite destinationSelectionGroup = new Composite(parent, SWT.NONE);
	GridLayout layout = new GridLayout();
	layout.numColumns = 3;
	destinationSelectionGroup.setLayout(layout);
	destinationSelectionGroup.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL
			| GridData.VERTICAL_ALIGN_FILL));
	destinationSelectionGroup.setFont(font);

	Label destinationLabel = new Label(destinationSelectionGroup, SWT.NONE);
	destinationLabel.setText(getDestinationLabel());
	destinationLabel.setFont(font);

	// destination name entry field
	destinationNameField = new Text(destinationSelectionGroup, SWT.BORDER);
	destinationNameField.addListener(SWT.Modify, this);
	destinationNameField.addListener(SWT.Selection, this);
	GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL);
	data.widthHint = SIZING_TEXT_FIELD_WIDTH;
	destinationNameField.setLayoutData(data);
	destinationNameField.setFont(font);

	// destination browse button
	destinationBrowseButton = new Button(destinationSelectionGroup, SWT.PUSH);
	destinationBrowseButton.setText(DataTransferMessages.DataTransfer_browse);
	destinationBrowseButton.addListener(SWT.Selection, this);
	destinationBrowseButton.setFont(font);
	setButtonLayoutData(destinationBrowseButton);

	new Label(parent, SWT.NONE); // vertical spacer
}
 
源代码16 项目: Pydev   文件: ScopedPreferencesFieldEditor.java
/**
 * Returns this field editor's link component.
 * <p>
 * The link is created if it does not already exist
 * </p>
 *
 * @param parent the parent
 * @return the label control
 */
private Button getButtonControl(Composite parent, String text) {
    Button button = new Button(parent, SWT.PUSH);
    button.setText(text);
    button.setFont(parent.getFont());

    GridData gd = createFillGridData();
    button.setLayoutData(gd);
    return button;
}
 
源代码17 项目: EasyShell   文件: MenuPage.java
private void createEditButton(Font font, GridData gridData, Composite groupComponent) {
    editButton = new Button(groupComponent, SWT.PUSH);
    editButton.setText(Activator.getResourceString("easyshell.menu.page.button.text.edit"));
    editButton.setToolTipText(Activator.getResourceString("easyshell.menu.page.button.tooltip.edit"));
    editButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent event) {
            editDialog();
        }
    });
    editButton.setLayoutData(gridData);
    editButton.setFont(font);
    setButtonLayoutData(editButton);
}
 
源代码18 项目: nebula   文件: MultiChoice.java
/**
 * Create the popup that contains all checkboxes
 */
private void createPopup() {
	this.popup = new Shell(getShell(), SWT.NO_TRIM | SWT.ON_TOP);
	this.popup.setLayout(new FillLayout());

	final int[] popupEvents = { SWT.Close, SWT.Deactivate, SWT.Dispose };
	for (final int popupEvent : popupEvents) {
		this.popup.addListener(popupEvent, this.listener);
	}

	if (this.elements == null) {
		return;
	}

	this.scrolledComposite = new ScrolledComposite(this.popup, SWT.BORDER | SWT.V_SCROLL);
	final Composite content = new Composite(this.scrolledComposite, SWT.NONE);
	content.setLayout(new GridLayout(this.numberOfColumns, true));

	this.checkboxes = new ArrayList<>(this.elements.size());
	for (final T o : this.elements) {
		final Button checkBoxButton = new Button(content, SWT.CHECK);

		if (this.font != null) {
			checkBoxButton.setFont(this.font);
		}
		if (this.foreground != null) {
			checkBoxButton.setForeground(this.foreground);
		}
		if (this.background != null) {
			checkBoxButton.setBackground(this.background);
		}
		checkBoxButton.setEnabled(text.getEditable());

		checkBoxButton.setData(o);
		checkBoxButton.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, false, false));
		checkBoxButton.setText(this.labelProvider.getText(o));
		checkBoxButton.addListener(SWT.Selection, e -> {
			if (checkBoxButton.getSelection()) {
				MultiChoice.this.selection.add(o);
			} else {
				MultiChoice.this.selection.remove(o);
			}
			MultiChoice.this.lastModified = o;
			setLabel();
		});

		if (this.selectionListener != null) {
			checkBoxButton.addSelectionListener(this.selectionListener);
		}

		checkBoxButton.setSelection(this.selection.contains(o));
		this.checkboxes.add(checkBoxButton);
	}

	this.scrolledComposite.setContent(content);
	this.scrolledComposite.setExpandHorizontal(false);
	this.scrolledComposite.setExpandVertical(true);
	content.pack();
	this.preferredHeightOfPopup = content.getSize().y;
}
 
源代码19 项目: birt   文件: FolderSelectionGroup.java
/**
 * 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 );
		}
	} );
}
 
源代码20 项目: birt   文件: NewReportPageSupport.java
/**
 * Creates the project location specification controls.
 * 
 * @param group
 *            the parent composite
 * @param enabled
 *            the initial enabled state of the widgets created
 */
private void createUserSpecifiedProjectLocationGroup( Composite group,
		boolean enabled )
{
	Font font = group.getFont( );

	// location label
	locationLabel = new Label( group, SWT.NONE );
	locationLabel.setText( LABEL_DIRECTORY );
	locationLabel.setEnabled( enabled );
	locationLabel.setFont( font );

	// file location entry field
	locationPathField = new Text( group, SWT.BORDER );
	GridData data = new GridData( GridData.FILL_HORIZONTAL );
	data.widthHint = 250;
	locationPathField.setLayoutData( data );
	locationPathField.setEnabled( enabled );
	locationPathField.setFont( font );

	// browse button
	browseButton = new Button( group, SWT.PUSH );
	browseButton.setText( LABEL_BROWSE );
	browseButton.addSelectionListener( new SelectionAdapter( ) {

		public void widgetSelected( SelectionEvent event )
		{
			handleLocationBrowseButtonPressed( );
		}
	} );

	browseButton.setEnabled( enabled );
	browseButton.setFont( font );
	setButtonLayoutData( browseButton );

	if ( defaultFileLocation != null )
	{
		locationPathField.setText( defaultFileLocation );
	}
	else
	{
		locationPathField.setText( "" );//$NON-NLS-1$
	}
}