Source Code : Display font in a grid
Java Is Open Source Programming Language You Can Download From Java and Java Libraries From http://www.oracle.com.
Click Here to download
We provide this code related to title for you to solve your developing problem easily. Libraries which is import in this program you can download from http://www.oracle.com.
Click Here or search from google with Libraries Name you get jar file related it
Display font in a grid
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);
}
}
Thank with us