String[] fonts = GraphicsEnvironment.
        getLocalGraphicsEnvironment().getAvailableFontFamilyNames();

解决方案 »

  1.   

    做好了,你看看吧:
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.Frame;class DemoFrame extends Frame
    {
    Panel P1 = new Panel(new FlowLayout(Label.LEFT));
    Label LB1 = new Label("字体列表");
    List L1 = new List(20);
    TextArea T1 = new TextArea(" " ,20, 20, 1);
    String[] fontNames; 
    public DemoFrame()
    {
    this.setTitle("字体列表演示");
    this.add(P1);
    P1.add(LB1);
    P1.add(L1);
    P1.add(T1);
    GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
    fontNames = env.getAvailableFontFamilyNames();
    for(int i = 0; i < fontNames.length; i++)
    {
    L1.addItem(fontNames[i]);
    }

    }
    }public class DemoFont 
    {
    public static void main(String args[])
    {
    DemoFrame D = new DemoFrame();
    D.setSize(500, 400);
    D.setVisible(true);
    }
    }
      

  2.   

    getAllFonts
    public abstract Font[] getAllFonts()
    Returns an array containing a one-point size instance of all fonts available in this GraphicsEnvironment. Typical usage would be to allow a user to select a particular font. Then, the application can size the font and set various font attributes by calling the deriveFont method on the choosen instance. 
    This method provides for the application the most precise control over which Font instance is used to render text. If a font in this GraphicsEnvironment has multiple programmable variations, only one instance of that Font is returned in the array, and other variations must be derived by the application. If a font in this environment has multiple programmable variations, such as Multiple-Master fonts, only one instance of that font is returned in the Font array. The other variations must be derived by the application. 
    Returns:
    an array of Font objects
    Since: 
    1.2 
    See Also:
    getAvailableFontFamilyNames(), Font, Font.deriveFont(int, float), Font.getFontName()