1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
/* Change Checkbox Background Color Example This java example shows how to change checkbox background color using AWT Checkbox class. */ import java.applet.Applet; import java.awt.Checkbox; import java.awt.Color; /* <applet code="ChangeCheckboxBackgroundExample" width=200 height=200> </applet> */ public class ChangeCheckboxBackgroundExample extends Applet{ public void init(){ //create checkboxes Checkbox checkbox1 = new Checkbox("Checkbox 1"); Checkbox checkbox2 = new Checkbox("Checkbox 2"); /* * To change background color of a checkbox use * setBackground(Color c) method. */ checkbox1.setBackground(Color.red); checkbox2.setBackground(Color.green); //add checkboxes add(checkbox1); add(checkbox2); } } |
Example Output
Add Comment