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); } } }); }
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; }
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); } } } }); }
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); } }
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); } } }); }
/** * * 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)); }
/** * @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()); }
@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)); }
@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)); }
/** 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(); }
@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)); } }
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())); } } }); }
/** * 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(); } } } }); }
/** * 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(); }
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; }
/** * 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); } }
/** * ��������ѡ��Ի��� * * @return */ public FontData getMoreFont() { FontDialog fd = new FontDialog(b); FontData font = fd.open(); return font; }