point-of-sales
Nama : Muhammad Fawwaz Zuhdan Nauvali
NRP : 05111740000106
Kelas : PBO-A
Membuat POS (point of sales) dalam java di bluej
Source code :
Input.java
Hasil Output
NRP : 05111740000106
Kelas : PBO-A
Membuat POS (point of sales) dalam java di bluej
Source code :
Input.java
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class Input {
JFrame frameList = null;
JPanel panel = null;
JTextField txtPetugas = null;
JTextField txtKBarang = null;
JTextField txtNBarang = null;
JTextField txtHarga = null;
JTextField txtJumlahBarang = null;
JFrame framePrint = null;
JPanel panelList = null;
public static void main(String[] args){
Input gui = new Input();
gui.go();
}
public void go(){
frameList = new JFrame();
frameList.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
panel = new JPanel();
JLabel lblPetugas = new JLabel("Nama Petugas:");
txtPetugas = new JTextField(20);
JLabel lblKBarang = new JLabel("Kode Barang:");
txtKBarang = new JTextField(20);
JLabel lblNBarang = new JLabel("Nama Barang:");
txtNBarang = new JTextField(20);
JLabel lblHarga = new JLabel("Harga:");
txtHarga = new JTextField(20);
JLabel lblJumlahBarang = new JLabel("Jumlah Barang:");
txtJumlahBarang = new JTextField(20);
JButton btnSubmit = new JButton("Print");
btnSubmit.addActionListener(new SubmitListener(this));
panel.add(lblPetugas);
panel.add(txtPetugas);
panel.add(lblKBarang);
panel.add(txtKBarang);
panel.add(lblNBarang);
panel.add(txtNBarang);
panel.add(lblHarga);
panel.add(txtHarga);
panel.add(lblJumlahBarang);
panel.add(txtJumlahBarang);
panel.add(btnSubmit);
frameList.getContentPane().add(BorderLayout.CENTER,panel);
frameList.setSize(250,500);
frameList.setVisible(true);
}
public void sendMessage(String msg) {
JOptionPane.showMessageDialog(null,msg);
}
public void printBarang(Input input) {
String petugasKasir = input.txtPetugas.getText();
String KBarang = input.txtKBarang.getText();
String NBarang = input.txtNBarang.getText();
String harga = input.txtHarga.getText();
String JumlahBarang = input.txtJumlahBarang.getText();
int totalHarga = Integer.parseInt(harga) * Integer.parseInt(JumlahBarang);
input.framePrint = new JFrame();
input.framePrint.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
input.panelList = new JPanel();
JLabel lblPetugas = new JLabel("Nama Petugas: " + input.txtPetugas.getText()+"\n");
JLabel lblKBarang = new JLabel("Kode Barang: " + input.txtKBarang.getText());
JLabel lblNBarang = new JLabel("Nama Barang: " + input.txtNBarang.getText());
JLabel lblHarga = new JLabel("Harga: Rp. " + input.txtHarga.getText());
JLabel lblJumlahBarang = new JLabel("Jumlah Barang: " + input.txtJumlahBarang.getText());
JLabel lblTotalBayar = new JLabel("Total Bayar: Rp. " + (Integer.parseInt(harga) * Integer.parseInt(JumlahBarang)));
input.panelList.add(lblPetugas);
input.panelList.add(lblKBarang);
input.panelList.add(lblNBarang);
input.panelList.add(lblHarga);
input.panelList.add(lblJumlahBarang);
input.panelList.add(lblTotalBayar);
input.framePrint.getContentPane().add(BorderLayout.CENTER, input.panelList);
input.framePrint.setSize(210,500);
input.frameList.setVisible(false);
input.framePrint.setVisible(true);
}
public class SubmitListener implements ActionListener{
Input input;
public SubmitListener(Input input) {
this.input = input;
}
public void actionPerformed(ActionEvent event){
input.printBarang(input);
}
}
}
Hasil Output
Komentar
Posting Komentar