Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <pre><code>GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); String[] fonts = ge.getAvailableFontFamilyNames(); </code></pre> <p>The sizes and styles can be set at run-time.</p> <h2>E.G.</h2> <p><img src="https://i.stack.imgur.com/hljMI.png" alt="Font Chooser"></p> <pre><code>import java.awt.*; import javax.swing.*; class ShowFonts { public static void main(String[] args) { SwingUtilities.invokeLater( new Runnable() { public void run() { GraphicsEnvironment ge = GraphicsEnvironment. getLocalGraphicsEnvironment(); String[] fonts = ge.getAvailableFontFamilyNames(); JComboBox fontChooser = new JComboBox(fonts); fontChooser.setRenderer(new FontCellRenderer()); JOptionPane.showMessageDialog(null, fontChooser); } }); } } class FontCellRenderer extends DefaultListCellRenderer { public Component getListCellRendererComponent( JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { JLabel label = (JLabel)super.getListCellRendererComponent( list,value,index,isSelected,cellHasFocus); Font font = new Font((String)value, Font.PLAIN, 20); label.setFont(font); return label; } } </code></pre> <h2>JavaDoc</h2> <p>The JDoc for <a href="http://download.oracle.com/javase/8/docs/api/java/awt/GraphicsEnvironment.html#getAvailableFontFamilyNames--" rel="noreferrer"><code>GraphicsEnvironment.getAvailableFontFamilyNames()</code></a> state in part..</p> <blockquote> <p>Returns an array containing the names of all font families in this <code>GraphicsEnvironment</code> localized for the default locale, as returned by <code>Locale.getDefault()</code>..</p> <h3>See also:</h3> <p><a href="http://download.oracle.com/javase/8/docs/api/java/awt/GraphicsEnvironment.html#getAllFonts--" rel="noreferrer"><code>getAllFonts()</code></a>..</p> </blockquote>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload