GUI
package Trial;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
class Demo extends JFrame implements ActionListener {
JButton jb1;
JCheckBox cb1, cb2, cb3;
Demo() {
setTitle("Hancie e-Learning Studio");
setLayout(null);
setSize(600, 500);
setLocationRelativeTo(null);
cb1 = new JCheckBox("Bhadrapur");
cb1.setBounds(50, 30, 150, 30);
add(cb1);
cb2 = new JCheckBox("Kathamandu");
cb2.setBounds(50, 60, 150, 30);
add(cb2);
cb3 = new JCheckBox("Pokhara");
cb3.setBounds(50, 90, 150, 30);
add(cb3);
jb1 = new JButton("Click");
jb1.setBounds(50, 200, 100, 30);
add(jb1);
jb1.addActionListener(this);
setVisible(true);
}
@Override
public void actionPerformed(ActionEvent e) {
String country = "";
if (cb1.isSelected()) {
country = country + "Bhadrapur\n";
}
if (cb2.isSelected()) {
country = country + "Kathamandu\n";
}
if (cb3.isSelected()) {
country = country + "Pokhara\n";
}
JOptionPane.showMessageDialog(this, country);
}
public static void main(String args[]) {
new Demo();
}
}
Output