Package PamView

Class JFontChooser

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable

public class JFontChooser extends JComponent
The JFontChooser class is a swing component for font selection. This class has JFileChooser like APIs. The following code pops up a font chooser dialog.
   JFontChooser fontChooser = new JFontChooser();
   int result = fontChooser.showDialog(parent);
   if (result == JFontChooser.OK_OPTION)
   {
      Font font = fontChooser.getSelectedFont(); 
      System.out.println("Selected Font : " + font); 
   }
 
See Also:
  • Field Details

  • Constructor Details

    • JFontChooser

      public JFontChooser()
      Constructs a JFontChooser object.
    • JFontChooser

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

    • getFontFamilyTextField

      public JTextField getFontFamilyTextField()
    • getFontStyleTextField

      public JTextField getFontStyleTextField()
    • getFontSizeTextField

      public JTextField getFontSizeTextField()
    • getFontFamilyList

      public JList getFontFamilyList()
    • getFontStyleList

      public JList getFontStyleList()
    • getFontSizeList

      public JList getFontSizeList()
    • getSelectedFontFamily

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

      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

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

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

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

      public void 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

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

      public void setSelectedFont(Font font)
      Set the selected font.
      Parameters:
      font - the selected font
      See Also:
    • getVersionString

      public String getVersionString()
    • showDialog

      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: