Java Code
/** Example showing checkbox with custom images
* @author : E.S.Boese
* @version: Fall 2008
*/
import javax.swing.*;
import java.awt.*;
public class JCheckBoxEx2 extends JApplet
{
Image notsel, selected;
ImageIcon notselIC, selectedIC;
JCheckBox cb1, cb2, cb3;
public void init( )
{
notsel = getImage( getCodeBase( ), "checkbox.png" );
notselIC = new ImageIcon( notsel );
selected = getImage( getCodeBase( ), "checkboxSelected.png" );
selectedIC = new ImageIcon( selected );
cb1 = new JCheckBox( "red", notselIC );
cb1.setSelectedIcon( selectedIC );
cb2 = new JCheckBox( "blue", notselIC );
cb2.setSelectedIcon( selectedIC );
cb3 = new JCheckBox( "pink", notselIC );
cb3.setSelectedIcon( selectedIC );
setLayout(new FlowLayout());
add( cb1 );
add( cb2 );
add( cb3 );
}
}
Back to Code Examples
©2006-
by E.S.Boese. All Rights Reserved