private void setSettings() {

    if (font.getText().equalsIgnoreCase(getFontString(Font.decode(null)))) {
      LocalSettings.setProperty(
          LocalSettings.DEFAULT_FONT, getFontString(jFontChooser1.getSelectedFont()));

    } else if (font.getText() != null
        && font.getText().length() > 0
        && !(getFontString(font.getText())).equalsIgnoreCase(getFontString(Font.decode(null)))) {
      LocalSettings.setProperty(LocalSettings.DEFAULT_FONT, getFontString(font.getText()));

    } else {
      Popup.notice(Messages.VALUE_NOT_VALID + font.getText());
    }

    jFontChooser1.setSelectedFont(
        Font.decode(LocalSettings.getProperty(LocalSettings.DEFAULT_FONT)));
    font.setText(getFontString(jFontChooser1.getSelectedFont()));

    applyFont(Font.decode(getFontString(font.getText())));
  }
Example #2
0
 /**
  * Similar to {@link #showFontDialog(Component, String)} except it can be called from a static
  * context. Prefer {@link #showFontDialog(Component, String)} if you want to control the dialog
  * created by the method call or if you want to specify a custom {@link FontChooserModel}.
  *
  * @param parent the parent <code>Component</code> for the dialog
  * @param title the String containing the dialog's title
  * @param initialFont the initial Font set when the font-chooser is shown
  * @return the selected font or <code>null</code> if the user opted out
  * @throws java.awt.HeadlessException if GraphicsEnvironment.isHeadless() returns true.
  * @see java.awt.GraphicsEnvironment#isHeadless
  * @see #showFontDialog(Component, String)
  */
 public static Font showDialog(Component parent, String title, Font initialFont) {
   JFontChooser chooser = new JFontChooser();
   chooser.setSelectedFont(initialFont);
   return chooser.showFontDialog(parent, title);
 }