Class BasicFontChooser

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, RootPaneContainer, WindowConstants

public class BasicFontChooser extends JDialog
BasicFontChooser is a dialog for choosing one of the available fonts. The size and style can also be selected. Usage follows that of JDialog (i.e. use the .show() method to reveal, dialogs can be modal or non-modal).
Version:
$Id$
Author:
Peter W. Draper
See Also:
  • Field Details

    • accepted

      protected boolean accepted
      Whether selected font is accepted.
    • contentPane

      protected JPanel contentPane
      The dialog contentpane.
    • fontLabel

      protected JLabel fontLabel
      Label for font selector.
    • sizeLabel

      protected JLabel sizeLabel
      Label for size selector.
    • styleLabel

      protected JLabel styleLabel
      Label for style selector.
    • styleBox

      protected JComboBox<String> styleBox
      List of possible styles.
    • sizeBox

      protected JComboBox<Integer> sizeBox
      List of pre-selected sizes.
    • fontBox

      protected JComboBox<String> fontBox
      List of all available fonts.
    • fontDisplay

      protected JTextField fontDisplay
      Display of the currently selected font.
    • okButton

      protected JButton okButton
      Accept and exit button.
    • cancelButton

      protected JButton cancelButton
      Cancel and exit button.
    • currentFont

      protected String currentFont
      Selected font name
    • currentSize

      protected int currentSize
      Selected font size.
    • currentStyle

      protected int currentStyle
      Selected font style.
  • Constructor Details

    • BasicFontChooser

      public BasicFontChooser()
      Construct an instance with default configuration.
    • BasicFontChooser

      public BasicFontChooser(String title)
      Construct an instance using the given window title.
    • BasicFontChooser

      public BasicFontChooser(Frame owner, String title, boolean modal)
      Construct an instance, setting the parent, window title and whether the dialog is modal.
  • Method Details

    • startup

      protected void startup()
      Start common initialisation sequence.
    • addFonts

      protected void addFonts()
      Add all the available fonts.
    • updateDisplay

      protected void updateDisplay()
      Update the display to reflect the new font, size or style.
    • setFontName

      protected void setFontName()
      Set a new default font name from the value in the font name combobox.
    • setSize

      protected void setSize()
      Set a new default font size from the value in the size combobox.
    • setStyle

      protected void setStyle()
      Set the font style from the value in the style combobox.
    • getSelectedFont

      public Font getSelectedFont()
      Get the selected font.
    • accepted

      public boolean accepted()
      Return the exit status of the dialog. The selected font should only be used if this returns true.
    • closeWindow

      protected void closeWindow(boolean accepted)
      Close the window. If argument is true then it is OK to return selected font.