Set JButton text bold

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

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


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

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

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

//Create font.
//Font Name : Default button font
//Font Style : Bold
//Font Size : Default button font size
Font newButtonFont=new Font(button.getFont().getName(),Font.BOLD,button.getFont().getSize());

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

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

//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
******************************************************************