চেকবক্স গ্রুপ

checkboxGroup  Checkbox এর মতই ,তবে প্রধান পার্থক্য হল এটি এক্তি গ্রুপের অধিনে থাকে । একটি select থাকলে আরেকটি unselect  থাকে ।এটিকে RadioButton বলা হয়। তেমন একটি প্রোগ্রাম নিচে দেওয়া হলঃ
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;

import javax.swing.JFrame;
import javax.swing.JOptionPane;

public class c7 extends JFrame implements ItemListener{
Checkbox check,uncheck;
CheckboxGroup gp;
c7(){
gp=new CheckboxGroup();
setLayout(new FlowLayout());
check=new Checkbox(“maried”,gp,false);
uncheck=new Checkbox(“UnMarried”,gp,false);
add(check);
add(uncheck);
check.addItemListener(this);
uncheck.addItemListener(this);

}
@Override
public void itemStateChanged(ItemEvent event) {

if(check.getState()){
JOptionPane.showMessageDialog(c7.this,” U are married 😦 You are going to hell”);

}

else JOptionPane.showMessageDialog(c7.this,”U are Unmarried , 🙂 You are full , Married Life is full of romance”);

}

public static void main(String arg[]){

c7 c=new c7();
c.setVisible(true);
c.setSize(400,400);
c.setDefaultCloseOperation(EXIT_ON_CLOSE);

}

}
chekboxGroup

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s