check box component

Source: Internet
Author: User

Package com.java.charpter12;

Import Java.awt.BorderLayout;
Import Java.awt.Container;
Import java.awt.event.ActionEvent;
Import Java.awt.event.ActionListener;

Import Javax.swing.JCheckBox;
Import Javax.swing.JFrame;
Import Javax.swing.JPanel;
Import Javax.swing.JScrollPane;
Import Javax.swing.JTextArea;
Import javax.swing.WindowConstants;

public class Checkboxtest extends jframe{
Private static final long serialversionuid=1l;
Private JPanel panel1=new JPanel ();//panel
Private JPanel panel2=new JPanel ();//panel
Private JTextArea jt=new JTextArea (3,10);//The panel is usually used for text
Private Jcheckbox jc1=new Jcheckbox ("1");
Private Jcheckbox jc2=new Jcheckbox ("2");
Private Jcheckbox jc3=new Jcheckbox ("3");


Public Checkboxtest ()
{
Container C=getcontentpane ();
SetSize (300, 400);
Settitle ("check box case");
SetVisible (TRUE);
Setdefaultcloseoperation (Windowconstants.exit_on_close);
C.setlayout (New BorderLayout ());
C.add (Panel1,borderlayout.north);
JScrollPane js=new JScrollPane (JT);//
Panel1.add (JS);
C.add (Panel2,borderlayout.south);
Panel2.add (JC1);
Jc1.addactionlistener (new ActionListener () {

@Override
public void actionperformed (ActionEvent e) {
if (jc1.isselected ()) {
Jt.append ("check box is first selected \ n");
}

}
});
Panel2.add (JC2);
Jc2.addactionlistener (new ActionListener () {

@Override
public void actionperformed (ActionEvent e) {
if (jc2.isselected ()) {
Jt.append ("check box 2 is selected \ n");
}

}
});

Panel2.add (JC3);
Jc3.addactionlistener (new ActionListener () {

@Override
public void actionperformed (ActionEvent e) {
if (jc3.isselected ()) {
Jt.append ("check box 3 is selected");
}
}
})
;





}
public static void Main (string[] args) {
New Checkboxtest ();
}
}

check box component

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.