Header Ads Widget

Responsive Advertisement

Ticker

6/recent/ticker-posts

Set JRadioButton text size (Java)

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

*****************************************************************
COMPLETE SOURCE CODE FOR : SetJRadioButtonTextSize.java
*****************************************************************
import javax.swing.JRadioButton;
import javax.swing.JFrame;
import javax.swing.SwingConstants;

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

public class SetJRadioButtonTextSize
{
public static void main(String[]args)
{
 //Create radio button using JRadioButton with text ( I am a radio button )
 JRadioButton radioButton=new JRadioButton("I am a radio button");

 //Create font.
 //Font Name : Default radio button font
 //Font Style : Default radio button font style
 //Font Size : 22
 Font newRadioButtonFont=new Font(radioButton.getFont().getName(),radioButton.getFont().getStyle(),22);

 //Set JRadioButton font using new created font
 radioButton.setFont(newRadioButtonFont);

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

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

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

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