Set JButton text font

Source code below will show you, how to set JButton text font.

***************************************************************
COMPLETE SOURCE CODE FOR : SetJButtonTextFont.java
***************************************************************


import javax.swing.JButton;
import javax.swing.JFrame;

import java.awt.FlowLayout;
import java.awt.Font;

public class SetJButtonTextFont
{
public static void main(String[]args)
{
//Create button with text ( MY BUTTON )
JButton button=new JButton("MY BUTTON");

//Create font.
//Font Name : Tahoma
//Font Style : Default button font style
//Font Size : Default button font size
Font newButtonFont=new Font("Tahoma",button.getFont().getStyle(),button.getFont().getSize());

//Set JButton font using new created font
button.setFont(newButtonFont);

//Create a window using JFrame with title ( Set JButton text font )
JFrame frame=new JFrame("Set JButton text font");

//Set JFrame layout to FlowLayout
frame.setLayout(new FlowLayout());

//Add created button into JFrame
frame.add(button);

//Set default close operation for JFrame
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

//Set JFrame size
frame.setSize(400,100);

//Make JFrame visible
frame.setVisible(true);
}
}


***************************************************************
JUST COMPILE AND EXECUTE IT
***************************************************************

RELAXING NATURE VIDEO