The example in this article describes the Java Swing Implementation check box method. Share to everyone for your reference. as follows:
Import java.awt.*;
Import javax.swing.*;
Import java.awt.event.*;
public class Test extends JApplet implements itemlistener{JTextField JTF;
public void init () {Container ContentPane = Getcontentpane ();
Contentpane.setlayout (New FlowLayout ());
ImageIcon A1 = new ImageIcon ("D:/data/images/6.gif");
ImageIcon A2 = new ImageIcon ("D:/data/images/7.gif");
ImageIcon a3 = new ImageIcon ("D:/data/images/8.gif");
Jcheckbox cb = new Jcheckbox ("C", A1);
Cb.setrollovericon (A2);
Cb.setselectedicon (A3);
Cb.additemlistener (this);
Contentpane.add (CB);
cb = new Jcheckbox ("C + +", A1);
Cb.setrollovericon (A2);
Cb.setselectedicon (A3);
Cb.additemlistener (this);
Contentpane.add (CB);
cb = new Jcheckbox ("Java", A1);
Cb.setrollovericon (A2);
Cb.setselectedicon (A3);
Cb.additemlistener (this);
Contentpane.add (CB);
JTF = new JTextField (15);
Contentpane.add (JTF); } public void itemstatechanged (ItemEvent IE) {Jcheckbox cb = (Jcheckbox) ie.getitem ();
Jtf.settext (Cb.gettext ());
}
}
I hope this article will help you with your Java programming.