Display font in a grid : Font « 2D Graphics « Java Tutorial

import java.awt.Font;
import java.awt.Graphics;

import javax.swing.JFrame;
import javax.swing.JPanel;

public class Main {
  public static void main(String[] args) {
    final int w = 20;
    final int side = 25;
    final int[][] grid = new int[50][w];

    JPanel panel = new JPanel() {
      public void paintComponent(Graphics g) {
        Font font = new Font("WingDings", Font.PLAIN, 14);
        int off = 0;
        for (int i = 0; i < 256 * 256; i++) {
          if (font.canDisplay((char) i)) {
            grid[off / w][off % w] = i;
            int x = off % w * side;
            int y = (off / w) * side + side;
            g.drawString("" + (char) i, x, y);
    JFrame frame = new JFrame();
    panel.setSize(300, 300);
    frame.setSize(300, 300);

16.23.2.Creating Serif FontCreating Serif Font
16.23.3.Create Bold and Italic fontCreate Bold and Italic font
16.23.4.Show fonts with mouse click
16.23.5.To change the size and/or style of a font, you call its deriveFont() methodTo change the size and/or style of a font, you call its deriveFont() method
16.23.6.Display font info.
16.23.7.To get all available fonts in your system
16.23.8.To get the font names
16.23.9.Show all Fonts installed in your systemShow all Fonts installed in your system
16.23.10.Fonts exercise: a font chooserFonts exercise: a font chooser
16.23.11.Display font in a grid
16.23.12.Create font from true type font
16.23.13.System fonts displaySystem fonts display