Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

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 columnCount = 10;
        final int side = 25;
        final int[][] grid = new int[50][columnCount];

        JPanel panel = new JPanel() {
            public void paintComponent(Graphics g) {
                Font font = new Font("WingDings", Font.PLAIN, 14);
                g.setFont(font);
                int off = 0;
                for (int i = 0; i < 256 * 256; i++) {
                    if (font.canDisplay((char) i) == false) {
                        continue;
                    }
                    off++;
                    grid[off / columnCount][off % columnCount] = i;
                    int x = off % columnCount * side;
                    int y = (off / columnCount) * side + side;
                    g.drawString(Character.toString((char) i), x, y);

                }
            }
        };
        JFrame frame = new JFrame();
        panel.setSize(300, 300);
        frame.getContentPane().add(panel);
        frame.setSize(300, 300);
        frame.setVisible(true);
    }
}