{"id":1225,"date":"2021-01-13T18:56:34","date_gmt":"2021-01-13T18:56:34","guid":{"rendered":"https:\/\/bhiggs.x10hosting.com\/PracticalJavaProgramming\/?page_id=1225"},"modified":"2021-01-13T19:11:09","modified_gmt":"2021-01-13T19:11:09","slug":"a-fontchooser-dialog","status":"publish","type":"page","link":"https:\/\/bhiggs.x10hosting.com\/PracticalJavaProgramming\/course-topics\/swing-gui-components\/dialog-boxes\/a-fontchooser-dialog\/","title":{"rendered":"A FontChooser Dialog"},"content":{"rendered":"\n<p>Strangely enough, the JDK doesn&#8217;t appear to have a&nbsp;<code><strong>JFontChooser<\/strong><\/code>&nbsp;dialog.&nbsp;&nbsp;<\/p>\n\n\n\n<p>So let&#8217;s implement one!<\/p>\n\n\n\n<p>What should it look like?&nbsp; Well, let&#8217;s see what other font dialogs look like, to get an idea.&nbsp; <\/p>\n\n\n\n<p>Here&#8217;s Microsoft Word 97&#8217;s Font dialog:<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"alignleft size-large\"><img fetchpriority=\"high\" decoding=\"async\" width=\"417\" height=\"454\" src=\"https:\/\/bhiggs.x10hosting.com\/PracticalJavaProgramming\/wp-content\/uploads\/2021\/01\/MSWordFontDialog.gif\" alt=\"\" class=\"wp-image-1229\"\/><\/figure><\/div>\n\n\n\n<div style=\"height:13px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>We don&#8217;t want to make it quite as complex as this one &#8212; at least as an example for this course &#8212; so let&#8217;s just restrict ourselves to the contents of the <strong>Font<\/strong> tab only, and to the list of Font names, styles, and sizes, and a <strong>Preview<\/strong>.<\/p>\n\n\n\n<p>Here&#8217;s what we&#8217;d like to see:<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"alignleft size-large\"><img decoding=\"async\" width=\"600\" height=\"400\" src=\"https:\/\/bhiggs.x10hosting.com\/PracticalJavaProgramming\/wp-content\/uploads\/2021\/01\/FontChooser.gif\" alt=\"\" class=\"wp-image-1230\"\/><\/figure><\/div>\n\n\n\n<div style=\"height:14px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>and here is an example of how we might call it:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: java; auto-links: false; highlight: [38,39,40,41,42]; title: ; quick-code: false; notranslate\" title=\"\">\npackage swingExamples;\n\nimport java.awt.Font;\n\nimport java.awt.event.ActionEvent;\nimport java.awt.event.ActionListener;\n\nimport javax.swing.JFrame;\nimport javax.swing.JMenu;\nimport javax.swing.JMenuBar;\nimport javax.swing.JMenuItem;\n\nclass FontChooserFrame extends JFrame\n{\n  public FontChooserFrame()\n  {\n    setTitle(&quot;FontChooserFrame&quot;);\n    setSize(600, 400);\n    setDefaultCloseOperation(EXIT_ON_CLOSE);\n\n    \/\/ Create menu bar with menu\n    JMenuBar menuBar = new JMenuBar();\n    setJMenuBar(menuBar);\n    JMenu formatMenu = new JMenu(&quot;Format&quot;);\n    JMenuItem fontItem = new JMenuItem(&quot;Font...&quot;);\n    fontItem.addActionListener(new ActionListener()\n    {\n      public void actionPerformed(ActionEvent e)\n      {\n        launchFontDialog();\n      }\n    }\n    );\n    formatMenu.add(fontItem);\n    menuBar.add(formatMenu);\n  }\n\n  private void launchFontDialog()\n  {\n    m_font = FontChooser.showDialog(\n                          this, &quot;Select font&quot;);\n  }\n\n  \/\/\/\/\/\/\/ Private data \/\/\/\/\/\/\/\n  private Font m_font;\n}\n\npublic class FontChooserExample\n{\n  public static void main(String&#x5B;] args)\n  {\n    FontChooserFrame frame = new FontChooserFrame();\n    frame.setVisible(true);\n  }\n}\n<\/pre><\/div>\n\n\n<p>So here&#8217;s how we implement the\u00a0<code><strong>FontChooser<\/strong><\/code>\u00a0dialog.\u00a0 I&#8217;ve modeled it after the code for <code><strong>JColorChooser<\/strong><\/code>, although I&#8217;ve simplified it somewhat.<\/p>\n\n\n\n<p>This is easily the most complex example in this course, so don&#8217;t be surprised if you have to study it for some time before you understand what it does, and how.<\/p>\n\n\n\n<p>Here it is:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: java; auto-links: false; title: ; quick-code: false; notranslate\" title=\"\">\npackage swingExamples;\n\nimport java.awt.BorderLayout;\nimport java.awt.Color;\nimport java.awt.Component;\nimport java.awt.Container;\nimport java.awt.Dimension;\nimport java.awt.FlowLayout;\nimport java.awt.Font;\nimport java.awt.GraphicsEnvironment;\nimport java.awt.Window;\n\nimport java.awt.event.ActionEvent;\nimport java.awt.event.ActionListener;\nimport java.awt.event.ComponentAdapter;\nimport java.awt.event.ComponentEvent;\nimport java.awt.event.WindowAdapter;\nimport java.awt.event.WindowEvent;\n\nimport javax.swing.Box;\nimport javax.swing.JButton;\nimport javax.swing.JComponent;\nimport javax.swing.JDialog;\nimport javax.swing.JLabel;\nimport javax.swing.JList;\nimport javax.swing.JOptionPane;\nimport javax.swing.JPanel;\nimport javax.swing.JScrollPane;\nimport javax.swing.JTextField;\n\nimport javax.swing.event.ListSelectionEvent;\nimport javax.swing.event.ListSelectionListener;\n\n\/**\n * FontChooser class, modelled after JColorChooser, \n * but simplified.\n *\n * @author Bryan Higgs, November 3, 2001\n *\/\n\npublic class FontChooser extends JComponent\n{\n  \/**\n   * Main entry point, for testing only.\n   *\/\n  public static void main(String&#x5B;] args)\n  {\n    Font font = FontChooser.showDialog( \n                    (Component)null, &quot;Font&quot;);\n    System.out.println(&quot;Font: &quot; + font);\n  }\n\n  \/**\n   * Shows the dialog, with specified parent and title.\n   *\/\n  public static Font showDialog(Component parent, String title)\n  {\n    final FontChooser pane = new FontChooser();\n\n    FontTracker ok = new FontTracker(pane);\n\n    JDialog dialog = \n        createDialog(parent, title, true, \/\/ modal\n                     pane, ok, null \/\/ No cancel listener\n        );\n    dialog.addWindowListener(\n        new FontChooserDialog.Closer());\n    dialog.addComponentListener(\n        new FontChooserDialog.DisposeOnClose());\n\n    dialog.setVisible(true); \n        \/\/ Blocks until user dismisses dialog\n\n    return ok.getSelectedFont();\n  }\n\n  \/**\n   * Creates and returns a new dialog containing the \n   * specified FontChooser pane, together with &quot;OK&quot; and \n   * &quot;Cancel&quot; buttons.\n   * If either of the &quot;OK&quot; or &quot;Cancel&quot; buttons is pressed, \n   * the dialog is automatically hidden (but not disposed).\n   *\/\n  public static JDialog createDialog(\n              Component parent, String title,\n              boolean modal,\n              FontChooser chooserPane,\n              ActionListener okListener,\n              ActionListener cancelListener)\n  {\n    return new FontChooserDialog(\n              parent, title, modal, chooserPane,\n              okListener, cancelListener);\n  }\n\n  \/**\n   * Constructor: Creates a font chooser pane, \n   * which consists of an input pane with three \n   * Lists for Font name, style and size, and a \n   * preview pane that shows some text in the \n   * selected font.\n   *\/\n  public FontChooser()\n  {\n    setLayout(new BorderLayout());\n\n    PreviewPanel previewPane = new PreviewPanel();\n    m_inputPane = new InputPanel(previewPane); \n                            \/\/ ListSelectionListener\n    add(m_inputPane, BorderLayout.CENTER);\n    add(previewPane, BorderLayout.SOUTH);\n  }\n\n  \/**\n   * Returns the current font from the font chooser.\n   * (Delegates the work to the input pane&#039;s getFont() \n   * method.)\n   *\/\n  public Font getSelectedFont()\n  {\n    return m_inputPane.getSelectedFont();\n  }\n\n  \/\/\/\/\/\/\/ Private data \/\/\/\/\/\n  private InputPanel m_inputPane;\n\n  \/\/\/\/\/\/\/ Inner classes \/\/\/\/\/\n\n  \/**\n   * Class to present the user with a set of \n   * three lists, one each for font name, style \n   * and size.\n   *\/\n  class InputPanel extends JPanel\n  {\n    \/**\n     * Constructor: Creates an instance of InputPanel.\n     *\n     * @param listener a list selection listener that \n     *                 will listen for changes in the \n     *                 state of the lists.\n     *\/\n    public InputPanel(ListSelectionListener listener)\n    {\n      setLayout(new BorderLayout());\n\n      \/\/ Font name\n      Box nameBox = Box.createVerticalBox();\n      nameBox.add(Box.createVerticalStrut(10));\n      JLabel fontNameLabel = new JLabel(&quot;Font Name:&quot;);\n      nameBox.add(fontNameLabel);\n      if (listener != null)\n      {\n        m_fontNameList.addListSelectionListener(listener);\n      }\n      JScrollPane namePane = \n                    new JScrollPane(m_fontNameList);\n      nameBox.add(namePane);\n      nameBox.add(Box.createVerticalStrut(10));\n\n      \/\/ Font style\n      Box styleBox = Box.createVerticalBox();\n      styleBox.add(Box.createVerticalStrut(10));\n      JLabel fontStyleLabel = new JLabel(&quot;Font Style:&quot;);\n      styleBox.add(fontStyleLabel);\n      if (listener != null)\n      {\n        m_fontStyleList.addListSelectionListener(listener);\n      }\n      JScrollPane stylePane = new JScrollPane(m_fontStyleList);\n      styleBox.add(stylePane);\n      styleBox.add(Box.createVerticalStrut(10));\n\n      \/\/ Font size\n      Box sizeBox = Box.createVerticalBox();\n      sizeBox.add(Box.createVerticalStrut(10));\n      JLabel fontSizeLabel = new JLabel(&quot;Size:&quot;);\n      sizeBox.add(fontSizeLabel);\n      if (listener != null)\n      {\n        m_fontSizeList.addListSelectionListener(listener);\n      }\n      JScrollPane sizePane = new JScrollPane(m_fontSizeList);\n      sizeBox.add(sizePane);\n      sizeBox.add(Box.createVerticalStrut(10));\n\n      Box mainBox = Box.createHorizontalBox();\n      mainBox.add(Box.createHorizontalStrut(10));\n      mainBox.add(nameBox);\n      mainBox.add(Box.createHorizontalStrut(10));\n      mainBox.add(styleBox);\n      mainBox.add(Box.createHorizontalStrut(10));\n      mainBox.add(sizeBox);\n      mainBox.add(Box.createHorizontalStrut(10));\n      add(mainBox, BorderLayout.CENTER);\n    }\n\n    \/**\n     * Returns the selected font, derived from the \n     * user&#039;s list choices.\n     *\/\n    public Font getSelectedFont()\n    {\n      return new Font(m_fontNameList.getFontName(),\n                      m_fontStyleList.getFontStyle(),\n                      m_fontSizeList.getFontSize()\n          );\n    }\n\n    \/\/\/\/\/\/\/\/\/\/\/\/ Private data \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\n    private FontNameList m_fontNameList = \n                            new FontNameList();\n    private FontStyleList m_fontStyleList = \n                            new FontStyleList();\n    private FontSizeList m_fontSizeList = \n                            new FontSizeList();\n  }\n\n  \/**\n   * Class to present a preview panel containing text \n   * that shows the selected font as the user chooses \n   * font attributes.\n   *\/\n  class PreviewPanel extends JPanel \n      implements ListSelectionListener\n  {\n    \/**\n     * Constructor: Creates an instance of PreviewPanel.\n     *\/\n    public PreviewPanel()\n    {\n      setLayout(new FlowLayout());\n\n      Box box = Box.createVerticalBox();\n      JLabel previewLabel = new JLabel(&quot;Preview:&quot;);\n      box.add(previewLabel);\n      m_text.setEditable(false);\n      m_text.setBackground(Color.white);\n      m_text.setForeground(Color.black);\n      JScrollPane pane = new JScrollPane(m_text);\n      pane.setPreferredSize(new Dimension(300, 80));\n      box.add(pane);\n\n      add(box);\n    }\n\n    \/**\n     * ListSelectionListener required method.\n     *\/\n    public void valueChanged(ListSelectionEvent ev)\n    {\n      m_text.setFont(FontChooser.this.getSelectedFont());\n    }\n\n    \/\/\/\/\/\/\/ Private data \/\/\/\/\/\/\/\n    private JTextField m_text = new JTextField(\n        &quot;The quick brown fox jumps over the lazy dog&quot;);\n  }\n}\n\n\/**\n * Class to present the list of available font names.\n *\/\nclass FontNameList extends JList\n{\n  \/**\n   * Constructor\n   *\/\n  FontNameList()\n  {\n    super(m_fontNames);\n    setSelectedIndex(0);\n    setVisibleRowCount(5);\n  }\n\n  \/**\n   * Returns the selected font name.\n   *\/\n  String getFontName()\n  {\n    String name = (String) getSelectedValue();\n    return name;\n  }\n\n  \/\/\/\/\/\/\/\/\/\/ Private data \/\/\/\/\/\/\/\/\/\n  private static final String&#x5B;] m_fontNames =\n      GraphicsEnvironment.getLocalGraphicsEnvironment().\n      getAvailableFontFamilyNames();\n}\n\n\/**\n * Class to present the available font styles.\n *\/\nclass FontStyleList extends JList\n{\n  \/**\n   * Constructor\n   *\/\n  FontStyleList()\n  {\n    super(m_fontStyles);\n    setSelectedIndex(0);\n    setVisibleRowCount(5);\n  }\n\n  \/**\n   * Returns the selected font style.\n   *\/\n  int getFontStyle()\n  {\n    int style = 0;\n    String name = (String) getSelectedValue();\n    if (name.equals(&quot;Regular&quot;))\n    {\n      style = Font.PLAIN;\n    }\n    else if (name.equals(&quot;Italic&quot;))\n    {\n      style = Font.ITALIC;\n    }\n    else if (name.equals(&quot;Bold&quot;))\n    {\n      style = Font.BOLD;\n    }\n    else\n    {\n      style = Font.BOLD + Font.ITALIC;\n    }\n    return style;\n  }\n\n  \/\/\/\/\/\/\/ Private data \/\/\/\/\/\/\/\/\/\/\n  private static final String&#x5B;] m_fontStyles =\n  {\n    &quot;Regular&quot;, &quot;Italic&quot;, &quot;Bold&quot;, &quot;Bold Italic&quot;\n  };\n}\n\n\/**\n * Class to present the available Font sizes.\n *\/\nclass FontSizeList extends JList\n{\n  \/**\n   * Constructor.\n   *\/\n  FontSizeList()\n  {\n    super(m_fontSizes);\n    setSelectedIndex(4); \/\/ Default to 14 point\n    setVisibleRowCount(5);\n  }\n\n  \/**\n   * Returns the selected font size.\n   *\/\n  int getFontSize()\n  {\n    int size = Integer.parseInt( \n                    (String) getSelectedValue());\n    return size;\n  }\n\n  \/\/\/\/\/\/\/\/\/\/ Private data \/\/\/\/\/\/\/\/\/\n  private static final String&#x5B;] m_fontSizes =\n  {\n    &quot;6&quot;, &quot;8&quot;, &quot;10&quot;, &quot;12&quot;, &quot;14&quot;, &quot;16&quot;, &quot;18&quot;, \n    &quot;20&quot;, &quot;22&quot;, &quot;24&quot;, &quot;36&quot;, &quot;72&quot;\n  };\n}\n\n\/**\n * Class to present a font chooser dialog, consisting \n * of a FontChooser panel with &quot;OK&quot; and &quot;Cancel&quot; buttons.\n *\/\nclass FontChooserDialog extends JDialog\n{\n  \/**\n   * Constructor: Creates an instance of a FontChooserDialog.\n   *\n   * @param component the parent component of the dialog\n   * @param title     the dialog title (for the title bar)\n   * @param modal     whether the dialog is modal\n   * @param chooserPane the FontChooser pane to be used\n   * @param okListener an ActionListener that listens \n   *                   to the OK button\n   * @param cancelListener an ActionListener that listens \n   *                   to the cancel button\n   *\/\n  public FontChooserDialog(\n                Component component, \n                String title, \n                boolean modal,\n                FontChooser chooserPane,\n                ActionListener okListener,\n                ActionListener cancelListener)\n  {\n    \/\/ Invoke JDialog&#039;s constructor, passing in the parent \n    \/\/ component&#039;s frame.\n    super(JOptionPane.getFrameForComponent(component), \n          title, modal);\n\n    m_chooserPane = chooserPane;\n\n    \/\/ Set contents of  dialog\n    Container contentPane = getContentPane();\n    contentPane.setLayout(new BorderLayout());\n    contentPane.add(m_chooserPane, BorderLayout.CENTER);\n\n    \/\/ Create lower button panel\n    JPanel buttonPane = new JPanel();\n    buttonPane.setLayout(new FlowLayout(FlowLayout.CENTER));\n\n    \/\/ OK Button\n    JButton okButton = new JButton(&quot;OK&quot;);\n    getRootPane().setDefaultButton(okButton);\n    okButton.setActionCommand(&quot;OK&quot;);\n    if (okListener != null)\n    {\n      okButton.addActionListener(okListener);\n    }\n    okButton.addActionListener(new ActionListener()\n    {\n      public void actionPerformed(ActionEvent e)\n      {\n        setVisible(false); \/\/ just hide the dialog\n      }\n    }\n    );\n    buttonPane.add(okButton);\n\n    \/\/ Cancel button\n    JButton cancelButton = new JButton(&quot;Cancel&quot;);\n    cancelButton.setActionCommand(&quot;cancel&quot;);\n    if (cancelListener != null)\n    {\n      cancelButton.addActionListener(cancelListener);\n    }\n    cancelButton.addActionListener(new ActionListener()\n    {\n      public void actionPerformed(ActionEvent e)\n      {\n        setVisible(false); \/\/ just hide the dialog\n      }\n    }\n    );\n    buttonPane.add(cancelButton);\n\n    contentPane.add(buttonPane, BorderLayout.SOUTH);\n\n    pack();\n    setLocationRelativeTo(component);\n  }\n\n  \/\/\/\/\/\/\/\/\/\/ Static nested classes \/\/\/\/\/\/\/\/\/\/\/\n\n  \/**\n   * Class to hide the dialog window on window closing event.\n   *\/\n  static class Closer extends WindowAdapter\n  {\n    public void windowClosing(WindowEvent e)\n    {\n      Window w = e.getWindow();\n      w.setVisible(false);\n    }\n  }\n\n  \/**\n   * Class to dispose of the dialog window when the \n   * dialog is hidden.\n   *\/\n  static class DisposeOnClose extends ComponentAdapter\n  {\n    public void componentHidden(ComponentEvent e)\n    {\n      Window w = (Window) e.getComponent();\n      w.dispose();\n    }\n  }\n\n  \/\/\/\/\/ Private data for FontChooserDialog \/\/\/\/\n  private FontChooser m_chooserPane;\n}\n\n\/**\n * Class to track changes in the selected font \n * in the FontChooser.\n *\/\nclass FontTracker implements ActionListener\n{\n  public FontTracker(FontChooser chooser)\n  {\n    m_chooser = chooser;\n  }\n\n  public void actionPerformed(ActionEvent e)\n  {\n    m_font = m_chooser.getSelectedFont();\n  }\n\n  public Font getSelectedFont()\n  {\n    return m_font;\n  }\n\n  \/\/\/\/\/\/\/\/\/ private data \/\/\/\/\/\/\/\/\/\n\n  private FontChooser m_chooser;\n  private Font m_font;\n}\n<\/pre><\/div>","protected":false},"excerpt":{"rendered":"<p>Strangely enough, the JDK doesn&#8217;t appear to have a&nbsp;JFontChooser&nbsp;dialog.&nbsp;&nbsp; So let&#8217;s implement one! What should it look like?&nbsp; Well, let&#8217;s see what other font dialogs look like, to get an idea.&nbsp; Here&#8217;s Microsoft Word 97&#8217;s Font dialog: We don&#8217;t want to make it quite as complex as this one &#8212; at least as an example [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"parent":1152,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_eb_attr":"","_uag_custom_page_level_css":"","ocean_post_layout":"left-sidebar","ocean_both_sidebars_style":"","ocean_both_sidebars_content_width":0,"ocean_both_sidebars_sidebars_width":0,"ocean_sidebar":"ocs-course-topics-sidebar","ocean_second_sidebar":"0","ocean_disable_margins":"enable","ocean_add_body_class":"","ocean_shortcode_before_top_bar":"","ocean_shortcode_after_top_bar":"","ocean_shortcode_before_header":"","ocean_shortcode_after_header":"","ocean_has_shortcode":"","ocean_shortcode_after_title":"","ocean_shortcode_before_footer_widgets":"","ocean_shortcode_after_footer_widgets":"","ocean_shortcode_before_footer_bottom":"","ocean_shortcode_after_footer_bottom":"","ocean_display_top_bar":"default","ocean_display_header":"default","ocean_header_style":"","ocean_center_header_left_menu":"0","ocean_custom_header_template":"0","ocean_custom_logo":0,"ocean_custom_retina_logo":0,"ocean_custom_logo_max_width":0,"ocean_custom_logo_tablet_max_width":0,"ocean_custom_logo_mobile_max_width":0,"ocean_custom_logo_max_height":0,"ocean_custom_logo_tablet_max_height":0,"ocean_custom_logo_mobile_max_height":0,"ocean_header_custom_menu":"0","ocean_menu_typo_font_family":"0","ocean_menu_typo_font_subset":"","ocean_menu_typo_font_size":0,"ocean_menu_typo_font_size_tablet":0,"ocean_menu_typo_font_size_mobile":0,"ocean_menu_typo_font_size_unit":"px","ocean_menu_typo_font_weight":"","ocean_menu_typo_font_weight_tablet":"","ocean_menu_typo_font_weight_mobile":"","ocean_menu_typo_transform":"","ocean_menu_typo_transform_tablet":"","ocean_menu_typo_transform_mobile":"","ocean_menu_typo_line_height":0,"ocean_menu_typo_line_height_tablet":0,"ocean_menu_typo_line_height_mobile":0,"ocean_menu_typo_line_height_unit":"","ocean_menu_typo_spacing":0,"ocean_menu_typo_spacing_tablet":0,"ocean_menu_typo_spacing_mobile":0,"ocean_menu_typo_spacing_unit":"","ocean_menu_link_color":"","ocean_menu_link_color_hover":"","ocean_menu_link_color_active":"","ocean_menu_link_background":"","ocean_menu_link_hover_background":"","ocean_menu_link_active_background":"","ocean_menu_social_links_bg":"","ocean_menu_social_hover_links_bg":"","ocean_menu_social_links_color":"","ocean_menu_social_hover_links_color":"","ocean_disable_title":"default","ocean_disable_heading":"default","ocean_post_title":"","ocean_post_subheading":"","ocean_post_title_style":"","ocean_post_title_background_color":"","ocean_post_title_background":0,"ocean_post_title_bg_image_position":"","ocean_post_title_bg_image_attachment":"","ocean_post_title_bg_image_repeat":"","ocean_post_title_bg_image_size":"","ocean_post_title_height":0,"ocean_post_title_bg_overlay":0.5,"ocean_post_title_bg_overlay_color":"","ocean_disable_breadcrumbs":"default","ocean_breadcrumbs_color":"","ocean_breadcrumbs_separator_color":"","ocean_breadcrumbs_links_color":"","ocean_breadcrumbs_links_hover_color":"","ocean_display_footer_widgets":"default","ocean_display_footer_bottom":"default","ocean_custom_footer_template":"0","footnotes":""},"class_list":["post-1225","page","type-page","status-publish","hentry","entry"],"uagb_featured_image_src":{"full":false,"thumbnail":false,"medium":false,"medium_large":false,"large":false,"1536x1536":false,"2048x2048":false,"ocean-thumb-m":false,"ocean-thumb-ml":false,"ocean-thumb-l":false},"uagb_author_info":{"display_name":"Bryan Higgs","author_link":"https:\/\/bhiggs.x10hosting.com\/PracticalJavaProgramming\/author\/bryan\/"},"uagb_comment_info":0,"uagb_excerpt":"Strangely enough, the JDK doesn&#8217;t appear to have a&nbsp;JFontChooser&nbsp;dialog.&nbsp;&nbsp; So let&#8217;s implement one! What should it look like?&nbsp; Well, let&#8217;s see what other font dialogs look like, to get an idea.&nbsp; Here&#8217;s Microsoft Word 97&#8217;s Font dialog: We don&#8217;t want to make it quite as complex as this one &#8212; at least as an example&hellip;","_links":{"self":[{"href":"https:\/\/bhiggs.x10hosting.com\/PracticalJavaProgramming\/wp-json\/wp\/v2\/pages\/1225","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/bhiggs.x10hosting.com\/PracticalJavaProgramming\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/bhiggs.x10hosting.com\/PracticalJavaProgramming\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/bhiggs.x10hosting.com\/PracticalJavaProgramming\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/bhiggs.x10hosting.com\/PracticalJavaProgramming\/wp-json\/wp\/v2\/comments?post=1225"}],"version-history":[{"count":4,"href":"https:\/\/bhiggs.x10hosting.com\/PracticalJavaProgramming\/wp-json\/wp\/v2\/pages\/1225\/revisions"}],"predecessor-version":[{"id":1233,"href":"https:\/\/bhiggs.x10hosting.com\/PracticalJavaProgramming\/wp-json\/wp\/v2\/pages\/1225\/revisions\/1233"}],"up":[{"embeddable":true,"href":"https:\/\/bhiggs.x10hosting.com\/PracticalJavaProgramming\/wp-json\/wp\/v2\/pages\/1152"}],"wp:attachment":[{"href":"https:\/\/bhiggs.x10hosting.com\/PracticalJavaProgramming\/wp-json\/wp\/v2\/media?parent=1225"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}