Package org.eclipse.swt.widgets

Examples of org.eclipse.swt.widgets.FontDialog


      new Label(s, SWT.NONE);
      final Button btnChange = new Button(s, SWT.PUSH | SWT.BORDER);
      btnChange.setText("Change Font");
      btnChange.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
          FontDialog fd = new FontDialog(s, SWT.NONE);
          fd.setText("Select Font");
          fd.setRGB(t.getForeground().getRGB());
          fd.setFontList(t.getFont().getFontData());

           FontData newFont = fd.open();
          if(newFont==null)
              return;
          t.setFont(new Font(d, newFont));
          t.setForeground(new Color(d, fd.getRGB()));
         
        }
      });
     
      Button btnSave = new Button(s, SWT.NONE);
View Full Code Here


                    new Object[] { value }));
        }
        valueChanged(oldValidState, newValidState);
    }   
  protected Object openDialogBox(Control cellEditorWindow) {
    FontDialog dialog = new FontDialog(cellEditorWindow.getShell());
    Object value = getValue();
    if (value != null) {
      dialog.setFontList(new FontData[] { (FontData) value });
    }
    value = dialog.open();
    FontData[] list = dialog.getFontList();
    return list == null ? null : list.length > 0 ? list[0] : null;
  }
View Full Code Here

    public boolean isDone() {
        return true;
    }

    public void perform() {
        dialog = new FontDialog(Display.getCurrent().getActiveShell());
        Font oldFont = getBoxPrinter().getFont();
        if (oldFont != null) {
            FontData fData = new FontData(oldFont.getName(), oldFont.getSize(), oldFont.getStyle());
            dialog.setFontList(new FontData[]{fData});
            Color fontColor = getBoxPrinter().getFontColor();
View Full Code Here

        fFont = new Font[1];
        fColor = new Color[1];

        fButton.setText(Messages.FontEditor_0);
        labelFontDialog = new FontDialog(new Shell());
        labelFontDialog.setText("Choose a Font"); //$NON-NLS-1$

        fButton.setImage(fImage);
        fButton.addSelectionListener(new SelectionAdapter(){
            public void widgetSelected( SelectionEvent event ) {
View Full Code Here

        button.addListener(SWT.Selection, new Listener(){

            public void handleEvent( Event event ) {

                final FontDialog dialog = new FontDialog(button.getShell());

                // setup default font
                IBlackboard blackboard = getStyleBlackboard();
                FontStyle fontStyle = (FontStyle) blackboard.get(FontStyleContent.ID);
                if (fontStyle != null) {
                    Font f = fontStyle.getFont();
                    FontData[] fd = AWTSWTImageUtils.awtFontToSwt(f,JFaceResources.getFontRegistry()).getFontData();
                    dialog.setFontList(fd);
                }
                // show dialog and get results
                FontData result = dialog.open();
                if (result != null) {
                    Font awtfont = AWTSWTImageUtils.swtFontToAwt(result);
                    fontStyle.setFont(awtfont);

                    swtFont = AWTSWTImageUtils.awtFontToSwt(awtfont, JFaceResources
View Full Code Here

        fFont = new Font[1];
        fColor = new Color[1];

        fButton.setText(Messages.FontEditor_SetFont);
        labelFontDialog = new FontDialog(new Shell());
        labelFontDialog.setText("Choose a Font"); //$NON-NLS-1$

        fButton.setImage(fImage);
        fButton.addSelectionListener(new SelectionAdapter(){
            public void widgetSelected( SelectionEvent event ) {
View Full Code Here

        Button fontButton = new Button(optionGroup, SWT.PUSH);
        fontButton.setText("Font");
        fontButton.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent arg0) {
                FontDialog dialog = new FontDialog(IComponentTestPanel.this.getShell());
                FontData fdata = dialog.open();
                if (fdata != null) {
                    Font font = new Font(Display.getCurrent(), fdata);
                    theComponent.setCometeFont(FontTool.getCometeFont(font));
                    font.dispose();
                    fontList.deselectAll();
View Full Code Here

  }
  /**
   * 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);
View Full Code Here

   * @since 3.2
   */
  private void editFont(Display display) {
    final FontDefinition definition = getSelectedFontDefinition();
    if (definition != null) {
      final FontDialog fontDialog = new FontDialog(fontChangeButton
          .getShell());
      fontDialog.setFontList(getFontValue(definition));
      final FontData data = fontDialog.open();
     
      if (data != null) {
        setFontPreferenceValue(definition, fontDialog.getFontList());
        setRegistryValue(definition, fontDialog.getFontList());
      }

      updateFontControls(definition);
    }
  }
View Full Code Here

                "Select..."));
        this.selectFontButton.addSelectionListener(
                new SelectionAdapter() {
                    public void widgetSelected(SelectionEvent event) {
                        // Create the font-change dialog
                        FontDialog dlg = new FontDialog(getShell());
                        dlg.setText(localizationResources.getString(
                                "Font_Selection"));
                        dlg.setFontList(new FontData[] {
                                SWTTitleEditor.this.titleFont });
                        if (dlg.open() != null) {
                            // Dispose of any fonts we have created
                            if (SWTTitleEditor.this.font != null) {
                                SWTTitleEditor.this.font.dispose();
                            }
                            // Create the new font and set it into the title
                            // label
                            SWTTitleEditor.this.font = new Font(
                                    getShell().getDisplay(), dlg.getFontList());
                            //titleField.setFont(font);
                            SWTTitleEditor.this.fontField.setText(
                                    SWTTitleEditor.this.font.getFontData()[0]
                                    .toString());
                            SWTTitleEditor.this.titleFont
                                    = SWTTitleEditor.this.font.getFontData()[0];
                        }
                    }
                }
        );
        // row 4
        new Label(general, SWT.NONE).setText(localizationResources.getString(
                "Color"));
        // Use a SwtPaintCanvas to show the color, note that we must set the
        // heightHint.
        final SWTPaintCanvas colorCanvas = new SWTPaintCanvas(general,
                SWT.NONE, this.titleColor);
        GridData canvasGridData = new GridData(SWT.FILL, SWT.CENTER, true,
                false);
        canvasGridData.heightHint = 20;
        colorCanvas.setLayoutData(canvasGridData);
        this.selectColorButton = new Button(general, SWT.PUSH);
        this.selectColorButton.setText(localizationResources.getString(
                "Select..."));
        this.selectColorButton.addSelectionListener(
                new SelectionAdapter() {
                    public void widgetSelected(SelectionEvent event) {
                        // Create the color-change dialog
                        ColorDialog dlg = new ColorDialog(getShell());
                        dlg.setText(localizationResources.getString(
                                "Title_Color"));
                        dlg.setRGB(SWTTitleEditor.this.titleColor.getRGB());
                        RGB rgb = dlg.open();
                        if (rgb != null) {
                            // create the new color and set it to the
                            // SwtPaintCanvas
                            SWTTitleEditor.this.titleColor = new Color(
                                    getDisplay(), rgb);
View Full Code Here

TOP

Related Classes of org.eclipse.swt.widgets.FontDialog

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.