Header Ads Widget

Responsive Advertisement

Ticker

6/recent/ticker-posts

Set JCheckBox text size (Java)

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

***************************************************************************
COMPLETE SOURCE CODE FOR : SetJCheckBoxTextSize.java
***************************************************************************
import javax.swing.JCheckBox;
import javax.swing.JFrame;
import javax.swing.SwingConstants;

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

public class SetJCheckBoxTextSize
{
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 : Default check box font style
 //Font Size : 22
 Font newCheckBoxFont=new Font(checkBox.getFont().getName(),checkBox.getFont().getStyle(),22);

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

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

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