Mega Code Archive

 
Categories / Java / Swing JFC
 

Customizing the Icons in a JCheckBox Component

import javax.swing.Icon; import javax.swing.ImageIcon; import javax.swing.JCheckBox; public class Main {   public static void main(String[] argv) throws Exception {     JCheckBox checkbox = new JCheckBox();     // Set the unselected state icon     Icon unselIcon = new ImageIcon("nosel-icon.gif");     checkbox.setIcon(unselIcon);     // Set the selected state icon     Icon selIcon = new ImageIcon("sel-icon.gif");     checkbox.setSelectedIcon(selIcon);   } }