Header Ads Widget

Responsive Advertisement

Ticker

6/recent/ticker-posts

Change java radio button text color (Java)

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

import java.awt.FlowLayout;
import java.awt.Color;

public class ChangeJavaRadioButtonTextColor
{
public static void main(String[]args)
{
 JRadioButton a=new JRadioButton("I AM A RADIO BUTTON");
 JFrame b=new JFrame("CHANGE RADIO BUTTON TEXT COLOR");
 b.setLayout(new FlowLayout());

 //METHOD setForeground will change radio button's text color
 //You can see more color in Color class on Java API
 a.setForeground(Color.GREEN);

 b.add(a);

 b.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
 b.setSize(400,400);
 b.setVisible(true);
}
}


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