public void widgetSelected( SelectionEvent arg0 ) { FontDialog fd = new FontDialog( shell ); fd.setFontList( new FontData[] { fixedFontData } ); FontData newfd = fd.open(); if ( newfd != null ) { fixedFontData = newfd; fixedFont.dispose(); fixedFont = new Font( display, fixedFontData ); wFFont.redraw(); } } } );
public void invokeFontDialog() { FontData fontData = new FontData(stringCustom); FontDialog fontWindow = new FontDialog(parent.getShell()); fontWindow.setFontList(new FontData[] { fontData }); fontWindow.setRGB(int2rgb(intgerCustom)); fontData = fontWindow.open(); if (fontData != null) { intgerCustom = rgb2int(fontWindow.getRGB()); stringCustom = fontData.toString(); toolButton.setToolTipText(font2string(fontData)); clickBody(); } }
/** * Constructs a new instance of this class given its parent * and a style value describing its behavior and appearance. * <p> * The style value is either one of the style constants defined in * class <code>SWT</code> which is applicable to instances of this * class, or must be built by <em>bitwise OR</em>'ing together * (that is, using the <code>int</code> "|" operator) two or more * of those <code>SWT</code> style constants. The class description * lists the style constants that are applicable to the class. * Style bits are also inherited from superclasses. * </p> * * @param parent a shell which will be the parent of the new instance * @param style the style of dialog to construct * * @exception IllegalArgumentException <ul> * <li>ERROR_NULL_ARGUMENT - if the parent is null</li> * </ul> * @exception SWTException <ul> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li> * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li> * </ul> */ public FontDialog (Shell parent, int style) { super (parent, checkStyle (parent, style)); checkSubclass (); }
FontDialog dialog = new FontDialog (shell, style); if (usePreviousResultButton.getSelection()) { dialog.setFontList (fontDialogFontListResult); dialog.setRGB(fontDialogColorResult); dialog.setEffectsVisible(effectsVisibleButton.getSelection()); dialog.setText (ControlExample.getResourceString("Title")); FontData result = dialog.open (); textWidget.append (ControlExample.getResourceString("FontDialog") + Text.DELIMITER); textWidget.append (ControlExample.getResourceString("Result", "" + result) + Text.DELIMITER); textWidget.append ("getFontList() =" + Text.DELIMITER); FontData [] fonts = dialog.getFontList (); if (fonts != null) { for (FontData font : fonts) { textWidget.append ("getEffectsVisible() = " + dialog.getEffectsVisible() + Text.DELIMITER); textWidget.append ("getRGB() = " + dialog.getRGB() + Text.DELIMITER + Text.DELIMITER); fontDialogFontListResult = dialog.getFontList (); fontDialogColorResult = dialog.getRGB(); return;
/** * Edit the given font. * * @param definition * the font definition * @param display * the display to open the dialog on * @since 3.7 */ private void editFont(FontDefinition definition, Display display) { if (definition != null) { final FontDialog fontDialog = new FontDialog(getShell()); fontDialog.setEffectsVisible(false); fontDialog.setFontList(getFontValue(definition)); final FontData data = fontDialog.open(); if (data != null) { setFontPreferenceValue(definition, fontDialog.getFontList(), false); refreshElement(definition); } } }
} else if (group.equals("options")) { tool.action = () -> { FontDialog fontDialog = new FontDialog(paintSurface.getShell(), SWT.PRIMARY_MODAL); FontData[] fontDatum = toolSettings.commonFont.getFontData(); if (fontDatum != null && fontDatum.length > 0) { fontDialog.setFontList(fontDatum); fontDialog.setText(getResourceString("options.Font.dialog.title")); FontData fontData = fontDialog.open(); paintSurface.showRubberband(); if (fontData != null) {
/** * Constructs a new instance of this class given its parent and a style value * describing its behavior and appearance. * <p> * The style value is either one of the style constants defined in class * <code>SWT</code> which is applicable to instances of this class, or must be * built by <em>bitwise OR</em>'ing together (that is, using the * <code>int</code> "|" operator) two or more of those <code>SWT</code> style * constants. The class description lists the style constants that are * applicable to the class. Style bits are also inherited from superclasses. * </p> * * @param parent a shell which will be the parent of the new instance * @param style the style of dialog to construct * @exception IllegalArgumentException <ul> * <li>ERROR_NULL_ARGUMENT - if the parent is null</li> * </ul> * @exception SWTException <ul> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the * thread that created the parent</li> * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed * subclass</li> * </ul> */ public FontDialog( Shell parent, int style ) { super( parent, checkStyle( parent, style ) ); checkSubclass(); setText( RWTMessages.getMessage( "RWT_FontDialogTitle" ) ); }
Font oldFont = itemFont; if (oldFont == null) oldFont = tabFolder1.getItem (0).getFont (); fontDialog.setFontList(oldFont.getFontData()); FontData fontData = fontDialog.open (); if (fontData == null) return; oldFont = itemFont;
final FontDialog dialog = new FontDialog(shell); if(self.getStringBlankAsNull("text") != null){ dialog.setText(self.getString("text")); return null; }else { FontData data = dialog.open(); self.doAction("open", actionContext, UtilMap.toMap("font", data));
FontDialog fontDialog = new FontDialog(); if (fontDialog.ShowDialog() == DialogResult.OK)
fontDialog = new FontDialog (shell); colorAndFontTable.addSelectionListener(widgetDefaultSelectedAdapter(event -> changeFontOrColor (colorAndFontTable.getSelectionIndex()))); changeButton.addSelectionListener(widgetSelectedAdapter(event -> changeFontOrColor (colorAndFontTable.getSelectionIndex())));
FontData data = d.open(); table.setFont(new Font(display, data)); for (int i = 0; i < titles.length; i++) {
@Override public void dialogClosed(int returnCode) { FontData[] list = dialog.getFontList(); if(list != null && list.length > 0){ FontData fontData = list[0]; String fontStr = fontData.getName() + "|" + fontData.getHeight() + "|" + fontData.getStyle(); if(dialog.getRGB() != null){ fontStr = fontStr + "|" + UtilSwt.RGBToString(dialog.getRGB()); } //fontStr = fontStr; text.setText(fontStr); ///UtilSwt.setFont(text, text.getText(), null); } text.setFocus(); }
private void selectFont () { try { FontDialog dlg = new FontDialog(dialog); dlg.setText("Select Font"); // Set current font and color info dlg.setFontList(opt.font.getFontData()); dlg.setRGB(opt.foreground.getRGB()); // Open the dialog FontData fontData = dlg.open(); if ( fontData == null) return; // If not canceled by user: We assign the new font // Work around: For some reason disposing of the font before calling edExample.setFont() // with the new font is causing an invalid argument exception. So we defer the dispose. Font tmp = opt.font; opt.font = new Font(device, fontData); edExample.setFont(opt.font); tmp.dispose(); // And the new new color opt.foreground.dispose(); opt.foreground = new Color(device, dlg.getRGB()); updateExample(); } catch ( Throwable e ) { Dialogs.showError(dialog, e.getLocalizedMessage(), null); } }
/** * Constructs a new instance of this class given its parent * and a style value describing its behavior and appearance. * <p> * The style value is either one of the style constants defined in * class <code>SWT</code> which is applicable to instances of this * class, or must be built by <em>bitwise OR</em>'ing together * (that is, using the <code>int</code> "|" operator) two or more * of those <code>SWT</code> style constants. The class description * lists the style constants that are applicable to the class. * Style bits are also inherited from superclasses. * </p> * * @param parent a shell which will be the parent of the new instance * @param style the style of dialog to construct * * @exception IllegalArgumentException <ul> * <li>ERROR_NULL_ARGUMENT - if the parent is null</li> * </ul> * @exception SWTException <ul> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li> * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li> * </ul> */ public FontDialog (Shell parent, int style) { super (parent, checkStyle (parent, style)); checkSubclass (); }
if (controls.length > 0) oldFont = controls [0].getFont (); if (oldFont != null) fontDialog.setFontList(oldFont.getFontData()); // seed dialog with current font FontData fontData = fontDialog.open (); if (fontData == null) return;
public void widgetSelected(SelectionEvent event) { final FontDialog dialog = new FontDialog(text.getShell()); FontData fontData = UtilSwt.parseFontData(text.getText()); if(fontData != null){ dialog.setFontList(new FontData[]{fontData}); dialog.setRGB(rgb); fontData = dialog.open(); if(fontData != null){ String fontStr = fontData.getName() + "|" + fontData.getHeight() + "|" + fontData.getStyle(); if(dialog.getRGB() != null){ fontStr = fontStr + "|" + UtilSwt.RGBToString(dialog.getRGB());
public void widgetSelected( SelectionEvent arg0 ) { FontDialog fd = new FontDialog( shell ); fd.setFontList( new FontData[] { graphFontData } ); FontData newfd = fd.open(); if ( newfd != null ) { graphFontData = newfd; graphFont.dispose(); graphFont = new Font( display, graphFontData ); wGFont.redraw(); } } } );
/** * Constructs a new instance of this class given its parent * and a style value describing its behavior and appearance. * <p> * The style value is either one of the style constants defined in * class <code>SWT</code> which is applicable to instances of this * class, or must be built by <em>bitwise OR</em>'ing together * (that is, using the <code>int</code> "|" operator) two or more * of those <code>SWT</code> style constants. The class description * lists the style constants that are applicable to the class. * Style bits are also inherited from superclasses. * </p> * * @param parent a shell which will be the parent of the new instance * @param style the style of dialog to construct * * @exception IllegalArgumentException <ul> * <li>ERROR_NULL_ARGUMENT - if the parent is null</li> * </ul> * @exception SWTException <ul> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li> * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li> * </ul> */ public FontDialog (Shell parent, int style) { super (parent, checkStyle (parent, style)); checkSubclass (); }
Font oldFont = itemFont; if (oldFont == null) oldFont = textNode1.getFont (); fontDialog.setFontList(oldFont.getFontData()); FontData fontData = fontDialog.open (); if (fontData == null) return; oldFont = itemFont; Font oldFont = cellFont; if (oldFont == null) oldFont = textNode1.getFont (1); fontDialog.setFontList(oldFont.getFontData()); FontData fontData = fontDialog.open (); if (fontData == null) return; oldFont = cellFont;