Java 类org.eclipse.swt.widgets.FontDialog 实例源码

项目:Hydrograph    文件:HeaderAndDataFormattingDialog.java   
private void addSelectionListeneronToFontButton(Button fontButton, TableEditor fontEditor) {
    fontButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            String fontdata = "";
            dialog = new FontDialog(Display.getCurrent().getActiveShell(), SWT.NONE);
            dialog.setText("Select Font");
            String string = formatMap.get(excelFormats[4]);
            fontdata = checkDefaultValue(fontEditor, fontdata, string);
            RGB checkDefaultColor = checkDefaultColor(fontdata, string);
            dialog.setRGB(checkDefaultColor);
            FontData defaultFont = new FontData(fontdata);
            dialog.setFontData(defaultFont);
            FontData newFont = dialog.open();
            RGB rgb = dialog.getRGB();
            String convertRGBToHEX = convertRGBToHEX(rgb);
            if (newFont != null) {
                fontEditor.getItem().setText(1, newFont.toString() + "|" + convertRGBToHEX);

            }
        }

    });
}
项目:TuxGuitar-1.3.1-fork    文件:TGMatrixConfig.java   
private FontData getFontChooser(final Composite parent,String title,FontData fontData){
    final FontData selection = new FontData(fontData.getName(),fontData.getHeight(),fontData.getStyle());

    Label label = new Label(parent, SWT.NULL);
    label.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, true, true));
    label.setText(title);

    Button button = new Button(parent, SWT.PUSH);
    button.setLayoutData(getAlignmentData(MINIMUM_CONTROL_WIDTH,SWT.FILL));
    button.setText(TuxGuitar.getProperty("choose"));
    button.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent arg0) {
            Font font = new Font(parent.getDisplay(),selection);
            FontDialog fontDialog = new FontDialog(parent.getShell());
            fontDialog.setFontList(font.getFontData());
            FontData fd = fontDialog.open();
            if(fd != null){
                selection.setName( fd.getName() );
                selection.setHeight( fd.getHeight() );
                selection.setStyle( fd.getStyle() );
            }
            font.dispose();
        }
    });
    return selection;
}
项目:TuxGuitar-1.3.1-fork    文件:StylesOption.java   
private void addFontButtonListeners(final Button button, final FontData fontData){
    button.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent arg0) {
            if(StylesOption.this.initialized){
                Font font = new Font(getDisplay(),fontData);
                FontData[] fontDataList = font.getFontData();
                font.dispose();
                FontDialog fontDialog = new FontDialog(getShell());
                fontDialog.setFontList(fontDataList);
                FontData result = fontDialog.open();
                if(result != null){
                    loadFontData(result, fontData,button);
                }
            }
        }
    });
}
项目:TuxGuitar-1.3.1-fork    文件:TGFretBoardConfig.java   
private FontData getFontChooser(final Composite parent,String title,FontData fontData){
    final FontData selection = new FontData(fontData.getName(),fontData.getHeight(),fontData.getStyle());

    Label label = new Label(parent, SWT.NULL);
    label.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, true, true));
    label.setText(title);

    Button button = new Button(parent, SWT.PUSH);
    button.setLayoutData(getAlignmentData(MINIMUM_CONTROL_WIDTH,SWT.FILL));
    button.setText(TuxGuitar.getProperty("choose"));
    button.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent arg0) {
            Font font = new Font(parent.getDisplay(),selection);
            FontDialog fontDialog = new FontDialog(parent.getShell());
            fontDialog.setFontList(font.getFontData());
            FontData fd = fontDialog.open();
            if(fd != null){
                selection.setName( fd.getName() );
                selection.setHeight( fd.getHeight() );
                selection.setStyle( fd.getStyle() );
            }
            font.dispose();
        }
    });
    return selection;
}
项目:mytourbook    文件:SimpleFontEditor.java   
private void onChangeFont() {

        FontData selectedFont;

        final FontDialog fontDialog = new FontDialog(_btnChangeFont.getShell());

        fontDialog.setFontList(_selectedFontData);
        fontDialog.setEffectsVisible(false);

        fireOpenEvent(true);
        {
            selectedFont = fontDialog.open();
        }
        fireOpenEvent(false);

        if (selectedFont != null) {
            fireFontChanged(selectedFont);
        }
    }
项目:translationstudio8    文件:FontPicker.java   
public FontPicker(final Composite parent, Font originalFont) {
    super(parent, SWT.NONE);
    if (originalFont == null) throw new IllegalArgumentException("null");

    update(originalFont.getFontData()[0]);

    addSelectionListener(
            new SelectionAdapter() {
                @Override
                public void widgetSelected(SelectionEvent e) {
                    FontDialog dialog = new FontDialog(new Shell(Display.getDefault(), SWT.SHELL_TRIM));
                    dialog.setFontList(fontData);
                    FontData selected = dialog.open();
                    if (selected != null) {                            
                        update(selected);
                        pack(true);
                    }
                }
            });
}
项目:tmxeditor8    文件:FontPicker.java   
public FontPicker(final Composite parent, Font originalFont) {
    super(parent, SWT.NONE);
    if (originalFont == null) throw new IllegalArgumentException("null");

    update(originalFont.getFontData()[0]);

    addSelectionListener(
            new SelectionAdapter() {
                @Override
                public void widgetSelected(SelectionEvent e) {
                    FontDialog dialog = new FontDialog(new Shell(Display.getDefault(), SWT.SHELL_TRIM));
                    dialog.setFontList(fontData);
                    FontData selected = dialog.open();
                    if (selected != null) {                            
                        update(selected);
                        pack(true);
                    }
                }
            });
}
项目:totallicks-tuxguitar    文件:MatrixConfig.java   
private FontData getFontChooser(final Composite parent,String title,FontData fontData){
    final FontData selection = new FontData(fontData.getName(),fontData.getHeight(),fontData.getStyle());

    Label label = new Label(parent, SWT.NULL);
    label.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, true, true));
    label.setText(title);

    Button button = new Button(parent, SWT.PUSH);
    button.setLayoutData(getAlignmentData(MINIMUM_CONTROL_WIDTH,SWT.FILL));
    button.setText(TuxGuitar.getProperty("choose"));
    button.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent arg0) {
            Font font = new Font(parent.getDisplay(),selection);
            FontDialog fontDialog = new FontDialog(parent.getShell());
            fontDialog.setFontList(font.getFontData());
            FontData fd = fontDialog.open();
            if(fd != null){
                selection.setName( fd.getName() );
                selection.setHeight( fd.getHeight() );
                selection.setStyle( fd.getStyle() );
            }
            font.dispose();
        }
    });
    return selection;
}
项目:totallicks-tuxguitar    文件:FretBoardConfig.java   
private FontData getFontChooser(final Composite parent,String title,FontData fontData){
    final FontData selection = new FontData(fontData.getName(),fontData.getHeight(),fontData.getStyle());

    Label label = new Label(parent, SWT.NULL);
    label.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, true, true));
    label.setText(title);

    Button button = new Button(parent, SWT.PUSH);
    button.setLayoutData(getAlignmentData(MINIMUM_CONTROL_WIDTH,SWT.FILL));
    button.setText(TuxGuitar.getProperty("choose"));
    button.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent arg0) {
            Font font = new Font(parent.getDisplay(),selection);
            FontDialog fontDialog = new FontDialog(parent.getShell());
            fontDialog.setFontList(font.getFontData());
            FontData fd = fontDialog.open();
            if(fd != null){
                selection.setName( fd.getName() );
                selection.setHeight( fd.getHeight() );
                selection.setStyle( fd.getStyle() );
            }
            font.dispose();
        }
    });
    return selection;
}
项目:totallicks-tuxguitar    文件:StylesOption.java   
private void addFontButtonListeners(final Button button, final FontData fontData){
    button.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent arg0) {
            if(StylesOption.this.initialized){
                Font font = new Font(getDisplay(),fontData);
                FontData[] fontDataList = font.getFontData();
                font.dispose();
                FontDialog fontDialog = new FontDialog(getShell());
                fontDialog.setFontList(fontDataList);
                FontData result = fontDialog.open();
                if(result != null){
                    loadFontData(result, fontData,button);
                }
            }
        }
    });
}
项目:NEXCORE-UML-Modeler    文件:AppearancePreferencePage.java   
/**
 * 
 * void
 */
private void openFontDialog() {
    FontDialog dialog = new FontDialog(UiCorePlugin.getShell(), SWT.NONE);
    if (fontListOfDialog[0] != null) {
        if (fontListOfDialog != fontList) {
            dialog.setFontList(fontListOfDialog);
        } else {
            dialog.setFontList(fontList);
        }
    } else {
        dialog.setFontList(fontList);
    }
    fontListOfDialog[0] = dialog.open();
    defaultFontPreviewLabel.setText(getFormatedFontString(fontListOfDialog));
}
项目:bts    文件:Test.java   
/**
 * @param args
 */
public static void main(String[] args)
{
    Display display = new Display();
    Shell shell = new Shell(display);
    //      displayAllLoadedFonts(shell);
    loadFont(shell, "amigaforeverpro2.ttf", 8);
    loadFont(shell, "E:/AAEW/dev/ws_bts_v2/org.bbaw.bts.ui.font.egyFont/font/FreeSerif.ttf", 8);
    displayAllLoadedFonts(shell);

    FontDialog dialog = new FontDialog(shell);
    dialog.open();
    Font f = new Font(display, dialog.getFontList());
}
项目:BrailleZephyr    文件:BZMenu.java   
@Override
public void widgetSelected(SelectionEvent ignored)
{
    FontDialog fontDialog = new FontDialog(parentShell, SWT.OPEN);
    fontDialog.setFontList(bzStyledText.getBrailleFont().getFontData());
    FontData fontData = fontDialog.open();
    if(fontData == null)
        return;
    bzStyledText.setBrailleFont(new Font(parentShell.getDisplay(), fontData));
}
项目:BrailleZephyr    文件:BZMenu.java   
@Override
public void widgetSelected(SelectionEvent ignored)
{
    FontDialog fontDialog = new FontDialog(parentShell, SWT.OPEN);
    fontDialog.setFontList(bzStyledText.getAsciiFont().getFontData());
    FontData fontData = fontDialog.open();
    if(fontData == null)
        return;
    bzStyledText.setAsciiFont(new Font(parentShell.getDisplay(), fontData));
}
项目:org.csstudio.display.builder    文件:FontCellEditor.java   
/** Opens the color dialog. */
@Override
public void activate()
{
    final FontDialog dialog = new FontDialog(shell);
    if (value != null)
        dialog.setFontList(new FontData[] { value });
    value = dialog.open();
    if (value != null)
        fireApplyEditorValue();
}
项目:gama    文件:FontEditor.java   
@Override
public void widgetSelected(final SelectionEvent e) {
    final FontDialog dialog = new FontDialog(WorkbenchHelper.getShell());
    dialog.setEffectsVisible(false);
    FontData data = toFontData(currentValue);
    dialog.setFontList(new FontData[] { data });
    data = dialog.open();
    if (data != null) {
        modifyAndDisplayValue(toGamaFont(data));
    }

}
项目:APICloud-Studio    文件:ThemePreferencePage.java   
private void createFontArea(Composite composite)
{
    Composite themesComp = new Composite(composite, SWT.NONE);
    themesComp.setLayout(new GridLayout(3, false));
    themesComp.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));

    Label label = new Label(themesComp, SWT.NONE);
    label.setText(Messages.ThemePreferencePage_FontNameLabel);

    fFont = JFaceResources.getFontRegistry().get(JFaceResources.TEXT_FONT);
    fFontText = new Text(themesComp, SWT.BORDER | SWT.SINGLE | SWT.READ_ONLY);
    fFontText.setText(toString(fFont));
    fFontText.setFont(fFont);
    fFontText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));

    Button selectFontButton = new Button(themesComp, SWT.PUSH);
    selectFontButton.setText(Messages.ThemePreferencePage_SelectFontButtonLabel);
    selectFontButton.addSelectionListener(new SelectionAdapter()
    {
        @Override
        public void widgetSelected(SelectionEvent e)
        {
            final FontDialog fontDialog = new FontDialog(getShell());
            fontDialog.setFontList(fFont.getFontData());
            final FontData data = fontDialog.open();
            if (data != null)
            {
                setFont(new Font(fFont.getDevice(), fontDialog.getFontList()));
            }
        }
    });
}
项目:drinviewer    文件:DrinViewer.java   
/**
 * shows font dialog and save user choice to preferences
 * 
 * @param isTitle true if must set font for title, false for text
 */
private void selectAndSaveFont (final boolean isTitle) {
    display.asyncExec(new Runnable() {
        @Override
        public void run() {
            FontDialog fd = new FontDialog(shell);
            fd.setText(DesktopDrinViewerConstants.i18nMessages.getString("selectfont"));
            fd.setRGB(new RGB(0, 0, 0));
            fd.setFontList(DrinViewer.getNotificationFont(display, isTitle));
            if (fd.open() != null) {
                // save font
                String namePref  = (isTitle) ? DesktopDrinViewerConstants.PREFS_TITLEFONTNAME : 
                       DesktopDrinViewerConstants.PREFS_TEXTFONTNAME;
                String sizePref  = (isTitle) ? DesktopDrinViewerConstants.PREFS_TITLEFONTSIZE :
                       DesktopDrinViewerConstants.PREFS_TEXTFONTSIZE;
                String stylePref = (isTitle) ? DesktopDrinViewerConstants.PREFS_TITLEFONTSTYLE :
                       DesktopDrinViewerConstants.PREFS_TEXTFONTSTYLE;

                prefs.put(namePref, fd.getFontList()[0].getName());
                prefs.putInt(sizePref, fd.getFontList()[0].getHeight());
                prefs.putInt(stylePref, fd.getFontList()[0].getStyle());
                try {
                    prefs.flush();
                } catch (BackingStoreException e) {
                    e.printStackTrace();
                }
            }
        }
    });     
}
项目:gef-gwt    文件:PaletteSettingsDialog.java   
/**
 * This method is invoked when the user selects the "Change" font button. It
 * opens the FontDialog to allow the user to change the font.
 */
protected void handleChangeFontPressed() {
    FontDialog dialog = new FontDialog(getShell());
    FontData data = prefs.getFontData();
    dialog.setFontList(new FontData[] { data });
    data = dialog.open();
    if (data != null) {
        prefs.setFontData(data);
    }
    updateFontName();
}
项目:q7.quality.mockups    文件:FontDialogTest.java   
public Control construct(Composite parent) {
    final Composite composite = new Composite(parent, SWT.NONE);
    GridDataFactory.swtDefaults().align(SWT.FILL, SWT.FILL)
            .grab(true, true).applyTo(composite);
    GridLayoutFactory.swtDefaults().numColumns(2).applyTo(composite);

    final Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();

    final Text t  = new Text(composite, SWT.BORDER | SWT.NONE);
    t.setText("Example text");
    t.setBounds(80, 2, 300, 20);

    Button button = new Button(composite, SWT.PUSH);
    button.setText("Change Font");
    button.setBounds(2, 30, 100, 30);

    button.addSelectionListener(new SelectionAdapter() {
      @SuppressWarnings("deprecation")
    public void widgetSelected(SelectionEvent e) {
        FontDialog fd = new FontDialog(shell, SWT.NONE);
        fd.setText("Select Font");
        fd.setRGB(new RGB(0, 0, 255));
        FontData defaultFont = new FontData("Courier", 10, SWT.BOLD);
        fd.setFontData(defaultFont);
        FontData newFont = fd.open();
        if (newFont == null)
          return;
        t.setFont(new Font(shell.getDisplay(), newFont));
        t.setForeground(new Color(shell.getDisplay(), fd.getRGB()));

      }
    });

    return null;

}
项目:patternbox-eclipse    文件:MultiPageEditor.java   
/**
 * Sets the font related data to be applied to the text in page 2.
 */
void setFont() {
    FontDialog fontDialog = new FontDialog(getSite().getShell());
    fontDialog.setFontList(text.getFont().getFontData());
    FontData fontData = fontDialog.open();
    if (fontData != null) {
        if (font != null)
            font.dispose();
        font = new Font(text.getDisplay(), fontData);
        text.setFont(font);
    }
}
项目:Black    文件:blackAction.java   
/**
 * ��������ѡ��Ի���
 * 
 * @return
 */
public FontData getMoreFont() {
    FontDialog fd = new FontDialog(b);
    FontData font = fd.open();
    return font;
}