0% found this document useful (0 votes)
11 views

CheckBoxExample .

checkbox project

Uploaded by

g37493252
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views

CheckBoxExample .

checkbox project

Uploaded by

g37493252
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

import javax.swing.

*;

import java.awt.event.*;

public class CheckBoxExample extends JFrame implements ActionListener

JLabel l;

JCheckBox cb1,cb2.cb3;

JButton b; CheckBoxExample f;

CheckBox Example()

I=new JLabel("Food Ordering System");

L.setBounds (50,50, 300,20); cb1=new JCheckBox("Pizza @ 100");

cb1.setBounds(100,100,150,20); cb2=new JCheckBox("Burger @ 30");

cb2.setBounds (100,150,150,20); b=new JButton("Order"); b.setBounds(100,250,80,30);


b.addActionListener(this);

cb3=new JCheckBox("Tea @ 10"); cb3.setBounds(100,200,150,20);

add(1); add(cb1); add(cb2); add(cb3); add(b);

public void actionPerformed(ActionEvent e)

float amount=0; String msg="";

if(cbl.isSelected())

amount+=100; // amount amount +100;

msg+="Pizza: 100\n";

if(cb2.isSelected())

amount+=30;

msg+="Burger: 30\n";

}
if(cb3.isSelected())

amount+=10;

msg+="Tea: 10\n";

msg+="

\n":

JOptionPane.showMessageDialog(f.msg+" Total: "+amount); }

public static void main (String[] args)

Check Box Example f = new CheckBoxExample();

f.setSize(400,400);

f.setLayout(null);

f.setVisible(true);

You might also like