⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fonts.java

📁 OpenJGraph是一个开源的Java库
💻 JAVA
字号:
package salvo.jesus.graph.java.awt;

import java.awt.*;

/**
 * A singleton class that gets all available fonts.
 *
 * @author  Jesus M. Salvo Jr. 
 */
public final class Fonts {
  /**
   * A reference to the single instance of Fonts
   */
  private static Fonts fontsInstance;

  /**
   * An array of String that holds the names of available fonts.
   */
  private String  fontsString[];

  /**
   * Private constructor so that no instance can be created externally from this class.
   */
  private Fonts(){
    GraphicsEnvironment gEnv = GraphicsEnvironment.getLocalGraphicsEnvironment();
    this.fontsString = gEnv.getAvailableFontFamilyNames();
  }

  /**
   * Returns a single instance of Fonts. If no instance has been created,
   * creates a new instance of Fonts. If an instance already exists,
   * simply returns the existing instance of Fonts.
   *
   * @return    Singleton Fonts object.
   */
  public static Fonts instance() {
    if( fontsInstance == null )
      fontsInstance = new Fonts();
    return fontsInstance;
  }

  /**
   * Returns the available Fonts in the system.
   *
   * @return  An array of Strings of the available fonts in the system.
   */
  public String[] getFonts() {
    return this.fontsString;
  }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -