You are on page 1of 5

import javax.swing.

*;

import java.awt.event.*;

public class GROUPG_ACTIVITY1

GROUPG_ACTIVITY1()

JFrame f = new JFrame("Variety Shop");

JTextArea frame = new JTextArea();

frame.setBounds (10,30,365,200);

frame.setLineWrap(true);

frame.setEditable(false);

JCheckBox Box1 = new JCheckBox();

Box1.setBounds (10,270,20,20);

JCheckBox Box2 = new JCheckBox();

Box2.setBounds(10,300,20,20);

JCheckBox Box3 = new JCheckBox ();

Box3.setBounds(10,330,20,20);

JLabel l1 = new JLabel("The Vault(Vape Pen)");

l1.setBounds(30,270,150,20);

JLabel ll1 = new JLabel("3000.00");

ll1.setBounds (180,270,150,20);

JLabel ll2 = new JLabel("Iphone 11");

ll2.setBounds(30,300,150,20);

JLabel ll3 = new JLabel("40000.00");

ll3.setBounds(180,300,150,20);
JLabel l2 = new JLabel("Matcha");

l2.setBounds (30,330,150,20);

JLabel l3 = new JLabel("90.00");

l3.setBounds(180,330,150,20);

JLabel label = new JLabel();

label.setBounds (10,225,200,20);

JLabel command = new JLabel("Check to Select an Item");

command.setBounds (10,250,200,20);

JTextField TX1 = new JTextField("0");

TX1.setBounds(250,270,50,20);

JTextField tx2 = new JTextField("0");

tx2.setBounds(250,300,50,20);

JTextField tx3 = new JTextField("0");

tx3.setBounds(250,330,50,20);

JButton button = new JButton("Buy");

button.setBounds(300,270,80,80);

f.add(frame);

f.add(Box1);

f.add(Box2);

f.add(Box3);

f.add(command);

f.add(label);

f.add(l1);
f.add(l2);

f.add(l3);

f.add(ll1);

f.add(ll2);

f.add(ll3);

f.add(TX1);

f.add(tx2);

f.add(tx3);

f.add(button);

f.setSize(400,400);

f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

f.setLayout(null);

f.setVisible(true);

Box1.addItemListener(new ItemListener() {

public void itemStateChanged(ItemEvent e) {

label.setText("Item # 1 is: "

+ (e.getStateChange()==1?"checked":"unchecked"));

});

Box2.addItemListener(new ItemListener() {

public void itemStateChanged(ItemEvent e) {

label.setText("Item # 2 is: "

+ (e.getStateChange()==1?"checked":"unchecked"));

});

Box3.addItemListener(new ItemListener() {

public void itemStateChanged(ItemEvent e) {


label.setText("Item # 3 is: "

+ (e.getStateChange()==1?"checked":"unchecked"));

});

button.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent e) {

if (Box1.isSelected() == true){

int fnum = Integer.parseInt(TX1.getText());

double snum = Double.parseDouble(ll1.getText());

double Answer = fnum * snum;

frame.append("You've Bought "+ fnum + " Pcs Vape Pen Worth : "+ Answer + "\n");

TX1.setEditable(true);

}else{

TX1.setEditable(false);

if (Box2.isSelected() == true){

int fnum = Integer.parseInt(tx2.getText());

double snum = Double.parseDouble(ll3.getText());

double Answer = fnum * snum;

frame.append("You've Bought "+ fnum + " Pcs Iphone Worth : "+ Answer + "\n");

tx2.setEditable(true);

}else{

tx2.setEditable(false);

if (Box3.isSelected() == true ){

int fnum = Integer.parseInt(tx3.getText());

double snum = Double.parseDouble(l3.getText());


double Answer = fnum * snum;

frame.append("You've Bought "+ fnum + " Pcs Matcha Worth : "+ Answer + "\n");

tx3.setEditable(true);

}else{

tx3.setEditable(false);

});

public static void main(String[] args)

new GROUPG_ACTIVITY1();

You might also like