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 Link icon

  • Constructor Details Link icon

    • JFontChooser Link icon

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

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

    • getFontFamilyTextField Link icon

      public JTextField getFontFamilyTextField()
    • getFontStyleTextField Link icon

      public JTextField getFontStyleTextField()
    • getFontSizeTextField Link icon

      public JTextField getFontSizeTextField()
    • getFontFamilyList Link icon

      public JList getFontFamilyList()
    • getFontStyleList Link icon

      public JList getFontStyleList()
    • getFontSizeList Link icon

      public JList getFontSizeList()
    • 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 void 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 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 Link icon

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

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

      public String getVersionString()
    • 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: