/** * 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" ) ); }
fontDialog.setFontList(fontDatum); fontDialog.setText(getResourceString("options.Font.dialog.title"));
dialog.setText (ControlExample.getResourceString("Title")); FontData result = dialog.open (); textWidget.append (ControlExample.getResourceString("FontDialog") + Text.DELIMITER);
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); } }
final FontDialog dialog = new FontDialog(shell); if(self.getStringBlankAsNull("text") != null){ dialog.setText(self.getString("text"));
private void selectFont () { try { FontDialog dlg = new FontDialog(getShell()); 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(getDisplay(), fontData); edExample.setFont(opt.font); tmp.dispose(); // And the new new color opt.foreground.dispose(); opt.foreground = new Color(getDisplay(), dlg.getRGB()); edExample.setForeground(opt.foreground); } catch ( Throwable e ) { Dialogs.showError(getShell(), e.getLocalizedMessage(), null); } }