Esempio n. 1
0
  /**
   * Registers a listener on the specified font chooser.
   *
   * <p>The specified listener will receive calls to its <code>setFont</code> method whenever the
   * font chooser has been updated.
   *
   * @param fontChooser chooser to monitor.
   * @param previewComponent component whose font should be tied to that of the chooser
   */
  protected void addFontChooserListener(FontChooser fontChooser, JComponent previewComponent) {
    // Update button font when a new font has been chosen in the FontChooser
    if (fontChooser != null) {
      ChangeListener listener;
      fontChooser.addChangeListener(listener = new PreviewFontChooserListener(previewComponent));
      previewComponent.setFont(fontChooser.getCurrentFont());

      // Hold a reference to this listener to prevent garbage collection
      listenerReferences.add(listener);
    }
  }
Esempio n. 2
0
  /**
   * Creates a font chooser that will keep the specified font up-to-date in the current theme data.
   *
   * @param fontId identifier of the font this chooser will be editing.
   */
  protected FontChooser createFontChooser(int fontId) {
    FontChooser fontChooser; // Font chooser that will be returned.
    ChangeListener listener; // Internal listener.

    // Initialises the font chooser.
    fontChooser = new FontChooser(themeData.getFont(fontId));
    fontChooser.setBorder(BorderFactory.createTitledBorder(Translator.get("theme_editor.font")));
    fontChooser.addChangeListener(
        listener = new ThemeFontChooserListener(themeData, fontId, parent));

    // Hold a reference to this listener to prevent garbage collection
    listenerReferences.add(listener);

    return fontChooser;
  }