/*
Change Checkbox Foreground Color Example
This java example shows how to change checkbox foreground color using
AWT Checkbox class.
*/
import java.applet.Applet;
import java.awt.Checkbox;
import java.awt.Color;
/*
<applet code="ChangeCheckboxForegroundExample" width=200 height=200>
</applet>
*/
public class ChangeCheckboxForegroundExample extends Applet{
public void init(){
//create checkboxes
Checkbox checkBox1 = new Checkbox("Checkbox 1");
Checkbox checkBox2 = new Checkbox("Checkbox 2");
/*
* To change foreground color of a checkbox use
* setForeground(Color c) method.
*/
checkBox1.setForeground(Color.magenta);
checkBox2.setForeground(Color.blue);
//add buttons
add(checkBox1);
add(checkBox2);
}
}
Example Output

Bookmark/Search this post with: