Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package tudlonisir;
- import java.awt.Color;
- import java.text.DecimalFormat;
- import java.awt.event.*;
- import javax.swing.*;
- /**
- *
- * @author college36
- */
- public class TudloNISir {
- private static final DecimalFormat df2 = new DecimalFormat("#.##");
- /**
- * @param args the command line arguments
- */
- public static JTextField TfSelectedP = new JTextField();
- public static JTextField TfPrice = new JTextField();
- public static JTextField TfQuantity = new JTextField();
- public static JTextField TfPayment = new JTextField();
- public static void maoNi( String pro, double prc){
- String m = JOptionPane.showInputDialog("Enter Quantity: (10 is the maximum)");
- Double number = Double.parseDouble(m);
- double price1 = prc;
- double max = 10;
- if(number <= max)
- {
- double totalpay = price1 * number;
- TfSelectedP.setText(""+ pro);
- TfPrice.setText("" + price1);
- TfQuantity.setText("" + number);
- TfPayment.setText("" + totalpay);
- }
- else
- {
- JOptionPane.showMessageDialog(null, "I said 10 is the Maximum",
- "Hey!", JOptionPane.ERROR_MESSAGE);
- }
- }
- public static void main(String[] args) {
- // TODO code application logic here
- JFrame jf = new JFrame();
- jf.setVisible(true);
- jf.setSize(800, 600);
- jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- jf.setLocationRelativeTo(null);
- jf.setLayout(null);
- JButton coke = new JButton();
- JButton jazz = new JButton();
- JButton sprite = new JButton();
- JButton seven_up = new JButton();
- JButton fanta = new JButton();
- JButton summit = new JButton();
- JButton pepsi = new JButton();
- JButton sparkle = new JButton();
- JLabel Select_Pro = new JLabel();
- JLabel Selected_Pro = new JLabel();
- JLabel price = new JLabel();
- JLabel Selected_Quan = new JLabel();
- JLabel Total = new JLabel();
- JLabel PriceL = new JLabel();
- JLabel coke1 = new JLabel();
- JLabel sprite1 = new JLabel();
- JLabel fanta1 = new JLabel();
- JLabel pepsi1 = new JLabel();
- jf.add(Select_Pro);
- Select_Pro.setText("SELECT PRODUCT");
- Select_Pro.setBounds(180, 25, 180, 100);
- jf.add(Selected_Pro);
- Selected_Pro.setText("SELECTED PRODUCT:");
- Selected_Pro.setBounds(500, 25, 180, 100);
- jf.add(TfSelectedP);
- TfSelectedP.setBounds(450, 100, 230, 25);
- jf.add(price);
- price.setText("PRICE:");
- price.setBounds(540, 90, 180, 100);
- jf.add(TfPrice);
- TfPrice.setBounds(450, 155, 230, 25);
- jf.add(Selected_Quan);
- Selected_Quan.setText("SELECTED QUANTITY:");
- Selected_Quan.setBounds(500, 145, 180, 100);
- jf.add(TfQuantity);
- TfQuantity.setBounds(450, 210, 230, 25);
- jf.add(Total);
- Total.setText("TOTAL PAYMENT:");
- Total.setBounds(515, 200, 180, 100);
- jf.add(TfPayment);
- TfPayment.setBounds(450, 265, 230, 25);
- jf.add(coke);
- coke.setText("COKE");
- coke.setBounds(50, 100, 180, 25);
- coke.setBackground(Color.red);
- jf.add(jazz);
- jazz.setText("JAZZ");
- jazz.setBounds(231, 100, 180, 25);
- jazz.setBackground(Color.pink);
- jf.add(sprite);
- sprite.setText("SPRITE");
- sprite.setBounds(50, 126, 180, 25);
- sprite.setBackground(Color.green);
- jf.add(seven_up);
- seven_up.setText("7 UP");
- seven_up.setBounds(231, 126, 180, 25);
- seven_up.setBackground(Color.pink);
- jf.add(fanta);
- fanta.setText("FANTA");
- fanta.setBounds(50, 152, 180, 25);
- fanta.setBackground(Color.orange);
- jf.add(summit);
- summit.setText("SUMMIT");
- summit.setBounds(231, 152, 180, 25);
- summit.setBackground(Color.blue);
- summit.setForeground(Color.white);
- jf.add(pepsi);
- pepsi.setText("PEPSI");
- pepsi.setBounds(50, 178, 180, 25);
- pepsi.setBackground(Color.BLUE);
- pepsi.setForeground(Color.white);
- jf.add(sparkle);
- sparkle.setText("SPARKLE");
- sparkle.setBounds(231, 178, 180, 25);
- sparkle.setBackground(Color.yellow);
- jf.add(PriceL);
- PriceL.setText(" PRICE LIST");
- PriceL.setBounds(203, 210, 180, 25);
- jf.add(coke1);
- coke1.setText("COKE = Php 12.00 JAZZ = Php 8.00");
- coke1.setBounds(120, 230, 300, 25);
- jf.add(sprite1);
- sprite1.setText(" SPRITE = Php 11.00 7 UP = Php 9.00");
- sprite1.setBounds(117, 250, 300, 25);
- jf.add(fanta1);
- fanta1.setText(" FANTA = Php 11.00 SUMMIT = Php 10.00");
- fanta1.setBounds(117, 270, 300, 25);
- jf.add(pepsi1);
- pepsi1.setText(" PEPSI = Php 12.00 SPARKLE = Php 8.00");
- pepsi1.setBounds(117, 290, 300, 25);
- coke.addActionListener((ActionEvent e) -> {
- maoNi("COKE", 12.00);
- });
- jazz.addActionListener((ActionEvent e) -> {
- maoNi("JAZZ", 8.00);
- });
- sprite.addActionListener((ActionEvent e) -> {
- maoNi("SPRITE", 11.00);
- });
- seven_up.addActionListener((ActionEvent e) -> {
- maoNi("SEVEN UP", 9.00);
- });
- fanta.addActionListener((ActionEvent e) -> {
- maoNi("FANTA", 11.00);
- });
- summit.addActionListener((ActionEvent e) -> {
- maoNi("SUMMIT", 10.00);
- });
- pepsi.addActionListener((ActionEvent e) -> {
- maoNi("PEPSI", 12.00);
- });
- sparkle.addActionListener((ActionEvent e) -> {
- maoNi("SPARKLE", 8.00);
- });
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement