Set JCheckBox text italic

Source code below will show you, how to set JCheckBox text to italic.

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


import javax.swing.JCheckBox;
import javax.swing.JFrame;
import javax.swing.SwingConstants;

import java.awt.BorderLayout;
import java.awt.Font;

public class SetJCheckBoxTextItalic
{
public static void main(String[]args)
{
//Create check box using JCheckBox with text ( I am a check box )
JCheckBox checkBox=new JCheckBox("I am a check box");

//Create font.
//Font Name : Default check box font
//Font Style : Italic
//Font Size : Default check box font size
Font newCheckBoxFont=new Font(checkBox.getFont().getName(),Font.ITALIC,checkBox.getFont().getSize());

//Set JCheckBox font using new created font
checkBox.setFont(newCheckBoxFont);

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

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

//Add created check box into JFrame
frame.add(checkBox);

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

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

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


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

RELAXING NATURE VIDEO