import javax.swing.
*
No category Today 5:22 pm
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
//LIBRARY
public class Finals { public static void
main(String[]args)
{
JFrame.setDefaultLookAndFeelDecorated(t
rue); //DESIGN FRAME
JFrame vp=new JFrame("VAPE SHOP"); //
CREATING FRAME
vp.setDefaultCloseOperation(JFrame.EXIT_
ON_CLOSE);// EXIT PROGRAMM
vp.setVisible(true);
//CREATING PANEL
JPanel panel=new JPanel();
panel.setBorder(BorderFactory.createTitled
Border("SELECT BRAND"));
JPanel panel2=new JPanel();
panel2.setBorder(BorderFactory.createTitle
dBorder("ITEMS"));
JPanel panel3=new JPanel();
panel3.setBorder(BorderFactory.createTitle
dBorder("TRANSACTION"));
//CREATING JFIELD
JTextField budget=new JTextField();
budget.setBounds(200, 200, 50, 5);
JTextField price=new JTextField();
price.setBounds(250, 250, 50, 5);
JTextField total=new JTextField();
total.setBounds(300, 250, 50, 5);
total.setEditable(false);
// ADD PANEL
panel3.add(budget);
panel3.add(price);
panel3.add(total);
//CREATING JLABEL
JLabel label=new JLabel();
label.setHorizontalTextPosition(JLabel.CEN
TER);
label.setBounds(40,50,100,400);
//CREATING JBUTTON
JButton geekvape=new
JButton("GEEKVAPE");
JButton voopoo=new
JButton("VOOOPOO");
JButton oxva=new JButton("OXVA");
//SET SIZE BUTTONS
geekvape.setBounds(20,50,90,20);
voopoo.setBounds(20,50,90,20);
oxva.setBounds(20,50,90,20);
vp.setSize(400,400);
vp.setLayout(new GridLayout(3,1));
panel.add(geekvape);
panel.add(voopoo);
panel.add(oxva);
//ADDING PANEL TO FRAME
vp.add(panel);
vp.add(panel2);
vp.add(panel3);
//FUNCTION OF BUTTONS
voopoo.addActionListener(new
ActionListener() {
@Override
public void
actionPerformed(ActionEvent e)
{
JButton enter=new JButton("TOTAL");
enter.setBounds(20,50,90,20);
panel3.add(enter);
String oppo1[]={ "GEEKVAPE 1500
PESOS"
,
"VOOOPOO 1350 PESOS"
,
"OXVA
1400 PESOS"};
JComboBox box1=new
JComboBox(voopoo1);
panel2.add(box1);
JButton select=new JButton("select");
select.setBounds(20,50,90 ,20);
panel2.add(select);
select.addActionListener(new
ActionListener()
{
@Override
public void
actionPerformed(ActionEvent e)
{
String choice=
"You selected: "+
box1.getItemAt(box1.getSelectedIndex());
label.setText(choice);
panel2.add(label);
String textfield1 =
budget.getText();
String textfield2 = total.getText();
String textfield3 = price.getText();
int a = Integer.parseInt(textfield1);
int b = Integer.parseInt(textfield2);
int price1 =
Integer.parseInt(textfield3);
int c = 0;
int z = 0;
if(e.getSource() == enter)
{
if(a > price1)
{
JOptionPane.showMessageDialog(null,
"Insufficient Money!!!");
}
else
{
z = a - price1;
String Fresult =
String.valueOf(z);
enter.setText(Fresult);
}
}
}
});
}
});
}
}