Package smile.swing

Class FontChooser

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable

public class FontChooser extends JComponent
The FontChooser class is a swing component for font selection with JFileChooser-like APIs. The following code pops up a font chooser dialog.
 
   FontChooser fontChooser = FontChooser.getInstance();
   int result = fontChooser.showDialog(parent);
   if (result == FontChooser.OK_OPTION) {
       Font font = fontChooser.getSelectedFont();
   }
 
 
See Also:
  • Field Details Link icon

  • Constructor Details Link icon

    • FontChooser Link icon

      public FontChooser()
      Constructs a FontChooser object.
    • FontChooser Link icon

      public FontChooser(String[] fontSizeStrings)
      Constructs a FontChooser object using the given font size array.
      Parameters:
      fontSizeStrings - the array of font size string.
  • Method Details Link icon

    • getMessage Link icon

      protected String getMessage(String key)
    • getInstance Link icon

      public static FontChooser getInstance()
      Returns the shared font chooser instance. In general, an application should have only one font chooser so that it always knows the latest chosen font.
    • getSelectedFontFamily Link icon

      public String getSelectedFontFamily()
      Get the family name of the selected font.
      Returns:
      the font family of the selected font.
      See Also:
    • getSelectedFontStyle Link icon

      public int getSelectedFontStyle()
      Get the style of the selected font.
      Returns:
      the style of the selected font. Font.PLAIN, Font.BOLD, Font.ITALIC, Font.BOLD|Font.ITALIC
      See Also:
    • getSelectedFontSize Link icon

      public int getSelectedFontSize()
      Get the size of the selected font.
      Returns:
      the size of the selected font
      See Also:
    • getSelectedFont Link icon

      public Font getSelectedFont()
      Get the selected font.
      Returns:
      the selected font
      See Also:
    • setSelectedFontFamily Link icon

      public FontChooser setSelectedFontFamily(String name)
      Set the family name of the selected font.
      Parameters:
      name - the family name of the selected font.
      See Also:
    • setSelectedFontStyle Link icon

      public FontChooser setSelectedFontStyle(int style)
      Set the style of the selected font.
      Parameters:
      style - the size of the selected font. Font.PLAIN, Font.BOLD, Font.ITALIC, or Font.BOLD|Font.ITALIC.
      See Also:
    • setSelectedFontSize Link icon

      public FontChooser setSelectedFontSize(int size)
      Set the size of the selected font.
      Parameters:
      size - the size of the selected font
      See Also:
    • setSelectedFont Link icon

      public FontChooser setSelectedFont(Font font)
      Set the selected font.
      Parameters:
      font - the selected font
      See Also:
    • showDialog Link icon

      public int showDialog(Component parent)
      Show font selection dialog.
      Parameters:
      parent - Dialog's Parent component.
      Returns:
      OK_OPTION, CANCEL_OPTION or ERROR_OPTION
      See Also: