Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.awt.FontMetrics;

import javax.swing.JFrame;

public class Main {
    public static void main(String args[]) {
        JFrame f = new JFrame("JColorChooser Sample");
        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        f.setSize(300, 200);
        f.setVisible(true);

        FontMetrics metrics = f.getFontMetrics(f.getFont());

        int widthX = metrics.charWidth('X');

        System.out.println(widthX);

    }
}