how-to

Graphics

How to create and set new font

For this sample you must use:

import java.awt.Font;

When you need create new font and this new font set for some item, use this code:

/* -- create new font */

Font font = new Font( "Magneto", Font.BOLD, 25 );

/* -- set font */

jLabel1.setFont( font );

First parameter is font name. You can use "Default" font (this font is set when your font name doesn`t exist).

Second parameter is style - could be Font.PLAIN for regular font style.

Third parameter is font size.