MainClass.java Source code

Java tutorial

Introduction

Here is the source code for MainClass.java

Source

import java.awt.Font;
import java.awt.FontFormatException;
import java.io.IOException;
import java.io.InputStream;

import javax.swing.JPanel;

public class MainClass extends JPanel {

    public void loadFont() throws FontFormatException, IOException {
        String fontFileName = "yourfont.ttf";
        InputStream is = this.getClass().getResourceAsStream(fontFileName);

        Font ttfBase = Font.createFont(Font.TRUETYPE_FONT, is);

        Font ttfReal = ttfBase.deriveFont(Font.PLAIN, 24);

    }

    public static void main(String[] args) {

    }

}