TOKO ELEKTRONIK SITANGGANG
Nama saya Herlinda Mita M. Sitanggang, saya adalah mahasiswa
dari STMIK Eresha. Disini saya membuat program sederhana dengan java swing atau
dengan kata lain sudah GUI (Graphic User Interface). Saya membuat program kasir
yang tergolong sederhana.
Saya akan menjelaskan,
Saya menggunakan dua (2) Variabel Integer, String . Lalu
saya menggunakan beberapa Method yaitu:
JUMLAH: untuk menampilkan jumlah barang item barang yang di
beli.
RUPIAH: Jumlah harga barang per item
JUMLAH BELANJA: untuk menampilkan Jumlah barang yang di beli
DISK 20%: untuk menghitung total bayar diskon 20% (Jika
belanja Rp.3.000.000)
TOTAL BAYAR: untuk menampilkan TOTAL BAYAR sebelum diskon
CASH: untuk pembayaran CASH
CARD: untuk pembayaran pake CARD (Jika pembayaran pake CARD
+ Diskon 10%)
VOUCHER: Untuk pembayaran pake VOUCHER (Jika pembayaran pake
Voucher mendapat potongan senilai nominal voucher tersebut.)
Ini adalah informasi untuk teks Variabelnya:
Nama Text Variabel
JLabel Judul jLabel1
Jlabel Kasir jLabel2
jLabel Nik jLabel3
jLabel TV jLabel4
jLabel DVD jLabel5
jLabel SOUND
SYSTEM jLabel6
jLabel RADIO
TAPE jLabel7
jLabel MICROFON jLabel8
jLabel ANTENA jLabel10
jlabel Nama
Barang jLabel11
jLabel jumlah jLabel12
jLabel Rupiah jLabel13
jLabel Pembayaran jLabel15
jLabel Jumlah
Belanja jLabel16
jRadio Button Disk
20% jRadio
Button1
Lebih detailnya akan saya tampilkn SOURCH kodenya,
/*
* 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.
*/
/**
*
* @author Mitha Sitanggang
*/
public class UTSJFRAME extends javax.swing.JFrame {
int tv,dvd,sound,radio,microfon,antena;
int total,ttv,tdvd,tsound,tradio,tmicrofon,tantena;
/**
* Creates new form UTSJFRAME
*/
public UTSJFRAME() {
initComponents();
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jLabel9 = new javax.swing.JLabel();
jTextField6 = new javax.swing.JTextField();
Judul = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
kasir = new javax.swing.JTextField();
jLabel4 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
jLabel6 = new javax.swing.JLabel();
jLabel7 = new javax.swing.JLabel();
jLabel8 = new javax.swing.JLabel();
jLabel10 = new javax.swing.JLabel();
jLabel11 = new javax.swing.JLabel();
jLabel12 = new javax.swing.JLabel();
jLabel13 = new javax.swing.JLabel();
JumlahTV = new javax.swing.JTextField();
JumlahDVD = new javax.swing.JTextField();
JumlahSound = new javax.swing.JTextField();
JumlahRadio = new javax.swing.JTextField();
JumlahMicrofon = new javax.swing.JTextField();
JumlahAntena = new javax.swing.JTextField();
HTV = new javax.swing.JTextField();
HDVD = new javax.swing.JTextField();
HSOUND = new javax.swing.JTextField();
HRADIO = new javax.swing.JTextField();
HMICROFON = new javax.swing.JTextField();
HANTENA = new javax.swing.JTextField();
jLabel14 = new javax.swing.JLabel();
jLabel15 = new javax.swing.JLabel();
TOTALBAYAR = new javax.swing.JTextField();
Diskon = new javax.swing.JRadioButton();
CARD = new javax.swing.JButton();
jLabel16 = new javax.swing.JLabel();
TotalItem = new javax.swing.JTextField();
jButton1 = new javax.swing.JButton();
nik = new javax.swing.JComboBox<>();
voucher = new javax.swing.JComboBox<>();
jLabel17 = new javax.swing.JLabel();
jLabel18 = new javax.swing.JLabel();
jLabel19 = new javax.swing.JLabel();
jLabel20 = new javax.swing.JLabel();
jLabel9.setText("jLabel9");
jTextField6.setText("jTextField6");
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
Judul.setText("TOKO ELEKTRONIC SITANGGANG");
jLabel2.setText("KASIR:");
jLabel3.setText("NIK :");
jLabel4.setText("TV");
jLabel5.setText("DVD");
jLabel6.setText("SOUND SYSTEM");
jLabel7.setText("RADIO TAPE");
jLabel8.setText("MICROFON");
jLabel10.setText("ANTENA");
jLabel11.setText("Nama Barang");
jLabel12.setText("Jumlah");
jLabel13.setText("Rupiah");
JumlahTV.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
JumlahTVActionPerformed(evt);
}
});
JumlahDVD.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
JumlahDVDActionPerformed(evt);
}
});
JumlahSound.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
JumlahSoundActionPerformed(evt);
}
});
JumlahRadio.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
JumlahRadioActionPerformed(evt);
}
});
JumlahMicrofon.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
JumlahMicrofonActionPerformed(evt);
}
});
JumlahAntena.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
JumlahAntenaActionPerformed(evt);
}
});
HTV.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
HTVActionPerformed(evt);
}
});
HDVD.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
HDVDActionPerformed(evt);
}
});
HRADIO.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
HRADIOActionPerformed(evt);
}
});
jLabel14.setText("Total Bayar :");
jLabel15.setText("Pembayaran :");
TOTALBAYAR.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
TOTALBAYARActionPerformed(evt);
}
});
Diskon.setText("Disc 20%");
Diskon.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
DiskonActionPerformed(evt);
}
});
CARD.setText("CARD");
CARD.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
CARDActionPerformed(evt);
}
});
jLabel16.setText("Jumlah Belanja");
TotalItem.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
TotalItemActionPerformed(evt);
}
});
jButton1.setText("CASH");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
nik.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Pilih", "161011400046", "161011400064", "161011400066" }));
nik.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
nikActionPerformed(evt);
}
});
voucher.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Voucher", "V1", "V2", "V3" }));
voucher.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
voucherActionPerformed(evt);
}
});
jLabel17.setText("*) CARD mendapat potongan 10%");
jLabel18.setText("*) V1 mendapat potongan senilai Rp. 20.000");
jLabel19.setText("*) V2 mendapat potongan senilai Rp. 50.000");
jLabel20.setText("*) V3 mendapat potongan senilai Rp. 100.000");
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(kasir, javax.swing.GroupLayout.PREFERRED_SIZE, 257, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addGap(20, 20, 20)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel10, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel11, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel12, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(JumlahTV, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(JumlahDVD, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(JumlahSound, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(JumlahRadio, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(JumlahMicrofon, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(JumlahAntena, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(28, 28, 28)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(HTV, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(HDVD, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(HSOUND, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(HRADIO, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(HMICROFON, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(HANTENA, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel13, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE))))
.addContainerGap(230, Short.MAX_VALUE))
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(layout.createSequentialGroup()
.addGap(20, 20, 20)
.addComponent(jLabel16, javax.swing.GroupLayout.PREFERRED_SIZE, 86, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
.addGap(39, 39, 39)
.addComponent(jLabel15)))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(TotalItem, javax.swing.GroupLayout.PREFERRED_SIZE, 92, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(Diskon, javax.swing.GroupLayout.PREFERRED_SIZE, 81, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addGap(4, 4, 4)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel17)
.addGroup(layout.createSequentialGroup()
.addComponent(jButton1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(CARD)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(voucher, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(jLabel18)
.addComponent(jLabel19)
.addComponent(jLabel20)))))
.addGroup(layout.createSequentialGroup()
.addGap(273, 273, 273)
.addComponent(jLabel14)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(TOTALBAYAR, javax.swing.GroupLayout.PREFERRED_SIZE, 81, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addGap(134, 134, 134)
.addComponent(Judul))
.addGroup(layout.createSequentialGroup()
.addGap(65, 65, 65)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 49, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(nik, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(Judul)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel3)
.addComponent(nik, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel2)
.addComponent(kasir, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(30, 30, 30)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(jLabel11, javax.swing.GroupLayout.PREFERRED_SIZE, 19, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel12)
.addComponent(jLabel13)))
.addGap(22, 22, 22)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel4)
.addComponent(JumlahTV, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(HTV, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(2, 2, 2)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel5)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(JumlahDVD, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(HDVD, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel6)
.addComponent(JumlahSound, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(HSOUND, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel7)
.addComponent(JumlahRadio, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(HRADIO, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(27, 27, 27)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel8)
.addComponent(HMICROFON, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(JumlahMicrofon, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(JumlahAntena, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addGap(18, 18, 18)
.addComponent(jLabel10, javax.swing.GroupLayout.PREFERRED_SIZE, 15, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGap(50, 50, 50))
.addGroup(layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(HANTENA, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel16, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(Diskon)
.addComponent(TotalItem, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel14, javax.swing.GroupLayout.PREFERRED_SIZE, 19, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(TOTALBAYAR, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(CARD)
.addComponent(jLabel15)
.addComponent(jButton1)
.addComponent(voucher, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel17)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jLabel18)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel19)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel20)
.addGap(35, 35, 35))
);
pack();
}// </editor-fold>
private void JumlahRadioActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
tradio = Integer.parseInt(JumlahRadio.getText());
radio = tradio * 1500000;
HRADIO.setText(""+radio);
}
private void JumlahAntenaActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
tantena = Integer.parseInt(JumlahAntena.getText());
antena = tantena * 500000;
HANTENA.setText(""+antena);
}
private void HTVActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void HDVDActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void HRADIOActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void CARDActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
int card, hcard,tcard;
card = Integer.parseInt(TOTALBAYAR.getText());
hcard = card / 20;
tcard = card - hcard;
TOTALBAYAR.setText(""+tcard);
}
private void JumlahTVActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
ttv = Integer.parseInt(JumlahTV.getText());
tv = ttv * 4000000;
HTV.setText(""+tv);
}
private void JumlahDVDActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
tdvd = Integer.parseInt(JumlahDVD.getText());
dvd = tdvd * 2000000;
HDVD.setText(""+dvd);
}
private void JumlahSoundActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
tsound = Integer.parseInt(JumlahSound.getText());
sound = tsound * 2500000;
HSOUND.setText(""+sound);
}
private void JumlahMicrofonActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
tmicrofon = Integer.parseInt(JumlahMicrofon.getText());
microfon = tmicrofon * 1000000;
HMICROFON.setText(""+microfon);
}
private void TOTALBAYARActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
total = tv+dvd+sound+radio+microfon+antena;
TOTALBAYAR.setText(""+total);
}
private void DiskonActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
if (Diskon.isSelected()){
int diskon, hdiskon;
diskon = total*20/100;
hdiskon = total - diskon;
TOTALBAYAR.setText("" + hdiskon);
}else {
TOTALBAYAR.setText(""+total);
}
}
private void TotalItemActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
int jumlahbelanja;
jumlahbelanja = ttv+tdvd+tsound+tradio+tmicrofon+tantena;
TotalItem.setText("" + jumlahbelanja);
}
private void nikActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
if(nik.getSelectedItem()=="Pilih"){
kasir.setText("");
}
else if(nik.getSelectedItem()=="161011400046"){
kasir.setText("Herlinda Mita M. Sitanggang");
}
else if(nik.getSelectedItem()=="161011400064"){
kasir.setText("Yuli Christiani Sitanggang");
}
else if(nik.getSelectedItem()=="161011400066"){
kasir.setText("Jhon M.A Sitanggang");
}
}
private void voucherActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
int jumlah1, jumlah2, jumlah3;
if (voucher.getSelectedItem()=="Voucher"){
TOTALBAYAR.setText(""+total);
}
if (voucher.getSelectedItem()=="V1"){
jumlah1=total-20000;
TOTALBAYAR.setText(""+jumlah1);
}
if (voucher.getSelectedItem()=="V2"){
jumlah2=total-50000;
TOTALBAYAR.setText(""+jumlah2);
}
if (voucher.getSelectedItem()=="V3"){
jumlah3=total-100000;
TOTALBAYAR.setText(""+jumlah3);
}
}
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
total = tv+dvd+sound+radio+microfon+antena;
TOTALBAYAR.setText(""+total);
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(UTSJFRAME.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(UTSJFRAME.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(UTSJFRAME.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(UTSJFRAME.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new UTSJFRAME().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton CARD;
private javax.swing.JRadioButton Diskon;
private javax.swing.JTextField HANTENA;
private javax.swing.JTextField HDVD;
private javax.swing.JTextField HMICROFON;
private javax.swing.JTextField HRADIO;
private javax.swing.JTextField HSOUND;
private javax.swing.JTextField HTV;
private javax.swing.JLabel Judul;
private javax.swing.JTextField JumlahAntena;
private javax.swing.JTextField JumlahDVD;
private javax.swing.JTextField JumlahMicrofon;
private javax.swing.JTextField JumlahRadio;
private javax.swing.JTextField JumlahSound;
private javax.swing.JTextField JumlahTV;
private javax.swing.JTextField TOTALBAYAR;
private javax.swing.JTextField TotalItem;
private javax.swing.JButton jButton1;
private javax.swing.JLabel jLabel10;
private javax.swing.JLabel jLabel11;
private javax.swing.JLabel jLabel12;
private javax.swing.JLabel jLabel13;
private javax.swing.JLabel jLabel14;
private javax.swing.JLabel jLabel15;
private javax.swing.JLabel jLabel16;
private javax.swing.JLabel jLabel17;
private javax.swing.JLabel jLabel18;
private javax.swing.JLabel jLabel19;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel20;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel8;
private javax.swing.JLabel jLabel9;
private javax.swing.JTextField jTextField6;
private javax.swing.JTextField kasir;
private javax.swing.JComboBox<String> nik;
private javax.swing.JComboBox<String> voucher;
// End of variables declaration
}
* 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.
*/
/**
*
* @author Mitha Sitanggang
*/
public class UTSJFRAME extends javax.swing.JFrame {
int tv,dvd,sound,radio,microfon,antena;
int total,ttv,tdvd,tsound,tradio,tmicrofon,tantena;
/**
* Creates new form UTSJFRAME
*/
public UTSJFRAME() {
initComponents();
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jLabel9 = new javax.swing.JLabel();
jTextField6 = new javax.swing.JTextField();
Judul = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
kasir = new javax.swing.JTextField();
jLabel4 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
jLabel6 = new javax.swing.JLabel();
jLabel7 = new javax.swing.JLabel();
jLabel8 = new javax.swing.JLabel();
jLabel10 = new javax.swing.JLabel();
jLabel11 = new javax.swing.JLabel();
jLabel12 = new javax.swing.JLabel();
jLabel13 = new javax.swing.JLabel();
JumlahTV = new javax.swing.JTextField();
JumlahDVD = new javax.swing.JTextField();
JumlahSound = new javax.swing.JTextField();
JumlahRadio = new javax.swing.JTextField();
JumlahMicrofon = new javax.swing.JTextField();
JumlahAntena = new javax.swing.JTextField();
HTV = new javax.swing.JTextField();
HDVD = new javax.swing.JTextField();
HSOUND = new javax.swing.JTextField();
HRADIO = new javax.swing.JTextField();
HMICROFON = new javax.swing.JTextField();
HANTENA = new javax.swing.JTextField();
jLabel14 = new javax.swing.JLabel();
jLabel15 = new javax.swing.JLabel();
TOTALBAYAR = new javax.swing.JTextField();
Diskon = new javax.swing.JRadioButton();
CARD = new javax.swing.JButton();
jLabel16 = new javax.swing.JLabel();
TotalItem = new javax.swing.JTextField();
jButton1 = new javax.swing.JButton();
nik = new javax.swing.JComboBox<>();
voucher = new javax.swing.JComboBox<>();
jLabel17 = new javax.swing.JLabel();
jLabel18 = new javax.swing.JLabel();
jLabel19 = new javax.swing.JLabel();
jLabel20 = new javax.swing.JLabel();
jLabel9.setText("jLabel9");
jTextField6.setText("jTextField6");
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
Judul.setText("TOKO ELEKTRONIC SITANGGANG");
jLabel2.setText("KASIR:");
jLabel3.setText("NIK :");
jLabel4.setText("TV");
jLabel5.setText("DVD");
jLabel6.setText("SOUND SYSTEM");
jLabel7.setText("RADIO TAPE");
jLabel8.setText("MICROFON");
jLabel10.setText("ANTENA");
jLabel11.setText("Nama Barang");
jLabel12.setText("Jumlah");
jLabel13.setText("Rupiah");
JumlahTV.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
JumlahTVActionPerformed(evt);
}
});
JumlahDVD.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
JumlahDVDActionPerformed(evt);
}
});
JumlahSound.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
JumlahSoundActionPerformed(evt);
}
});
JumlahRadio.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
JumlahRadioActionPerformed(evt);
}
});
JumlahMicrofon.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
JumlahMicrofonActionPerformed(evt);
}
});
JumlahAntena.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
JumlahAntenaActionPerformed(evt);
}
});
HTV.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
HTVActionPerformed(evt);
}
});
HDVD.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
HDVDActionPerformed(evt);
}
});
HRADIO.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
HRADIOActionPerformed(evt);
}
});
jLabel14.setText("Total Bayar :");
jLabel15.setText("Pembayaran :");
TOTALBAYAR.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
TOTALBAYARActionPerformed(evt);
}
});
Diskon.setText("Disc 20%");
Diskon.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
DiskonActionPerformed(evt);
}
});
CARD.setText("CARD");
CARD.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
CARDActionPerformed(evt);
}
});
jLabel16.setText("Jumlah Belanja");
TotalItem.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
TotalItemActionPerformed(evt);
}
});
jButton1.setText("CASH");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
nik.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Pilih", "161011400046", "161011400064", "161011400066" }));
nik.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
nikActionPerformed(evt);
}
});
voucher.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Voucher", "V1", "V2", "V3" }));
voucher.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
voucherActionPerformed(evt);
}
});
jLabel17.setText("*) CARD mendapat potongan 10%");
jLabel18.setText("*) V1 mendapat potongan senilai Rp. 20.000");
jLabel19.setText("*) V2 mendapat potongan senilai Rp. 50.000");
jLabel20.setText("*) V3 mendapat potongan senilai Rp. 100.000");
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(kasir, javax.swing.GroupLayout.PREFERRED_SIZE, 257, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addGap(20, 20, 20)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel10, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel11, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel12, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(JumlahTV, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(JumlahDVD, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(JumlahSound, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(JumlahRadio, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(JumlahMicrofon, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(JumlahAntena, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(28, 28, 28)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(HTV, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(HDVD, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(HSOUND, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(HRADIO, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(HMICROFON, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(HANTENA, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel13, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE))))
.addContainerGap(230, Short.MAX_VALUE))
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(layout.createSequentialGroup()
.addGap(20, 20, 20)
.addComponent(jLabel16, javax.swing.GroupLayout.PREFERRED_SIZE, 86, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
.addGap(39, 39, 39)
.addComponent(jLabel15)))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(TotalItem, javax.swing.GroupLayout.PREFERRED_SIZE, 92, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(Diskon, javax.swing.GroupLayout.PREFERRED_SIZE, 81, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addGap(4, 4, 4)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel17)
.addGroup(layout.createSequentialGroup()
.addComponent(jButton1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(CARD)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(voucher, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(jLabel18)
.addComponent(jLabel19)
.addComponent(jLabel20)))))
.addGroup(layout.createSequentialGroup()
.addGap(273, 273, 273)
.addComponent(jLabel14)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(TOTALBAYAR, javax.swing.GroupLayout.PREFERRED_SIZE, 81, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addGap(134, 134, 134)
.addComponent(Judul))
.addGroup(layout.createSequentialGroup()
.addGap(65, 65, 65)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 49, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(nik, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(Judul)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel3)
.addComponent(nik, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel2)
.addComponent(kasir, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(30, 30, 30)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(jLabel11, javax.swing.GroupLayout.PREFERRED_SIZE, 19, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel12)
.addComponent(jLabel13)))
.addGap(22, 22, 22)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel4)
.addComponent(JumlahTV, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(HTV, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(2, 2, 2)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel5)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(JumlahDVD, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(HDVD, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel6)
.addComponent(JumlahSound, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(HSOUND, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel7)
.addComponent(JumlahRadio, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(HRADIO, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(27, 27, 27)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel8)
.addComponent(HMICROFON, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(JumlahMicrofon, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(JumlahAntena, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addGap(18, 18, 18)
.addComponent(jLabel10, javax.swing.GroupLayout.PREFERRED_SIZE, 15, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGap(50, 50, 50))
.addGroup(layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(HANTENA, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel16, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(Diskon)
.addComponent(TotalItem, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel14, javax.swing.GroupLayout.PREFERRED_SIZE, 19, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(TOTALBAYAR, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(CARD)
.addComponent(jLabel15)
.addComponent(jButton1)
.addComponent(voucher, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel17)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jLabel18)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel19)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel20)
.addGap(35, 35, 35))
);
pack();
}// </editor-fold>
private void JumlahRadioActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
tradio = Integer.parseInt(JumlahRadio.getText());
radio = tradio * 1500000;
HRADIO.setText(""+radio);
}
private void JumlahAntenaActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
tantena = Integer.parseInt(JumlahAntena.getText());
antena = tantena * 500000;
HANTENA.setText(""+antena);
}
private void HTVActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void HDVDActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void HRADIOActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void CARDActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
int card, hcard,tcard;
card = Integer.parseInt(TOTALBAYAR.getText());
hcard = card / 20;
tcard = card - hcard;
TOTALBAYAR.setText(""+tcard);
}
private void JumlahTVActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
ttv = Integer.parseInt(JumlahTV.getText());
tv = ttv * 4000000;
HTV.setText(""+tv);
}
private void JumlahDVDActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
tdvd = Integer.parseInt(JumlahDVD.getText());
dvd = tdvd * 2000000;
HDVD.setText(""+dvd);
}
private void JumlahSoundActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
tsound = Integer.parseInt(JumlahSound.getText());
sound = tsound * 2500000;
HSOUND.setText(""+sound);
}
private void JumlahMicrofonActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
tmicrofon = Integer.parseInt(JumlahMicrofon.getText());
microfon = tmicrofon * 1000000;
HMICROFON.setText(""+microfon);
}
private void TOTALBAYARActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
total = tv+dvd+sound+radio+microfon+antena;
TOTALBAYAR.setText(""+total);
}
private void DiskonActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
if (Diskon.isSelected()){
int diskon, hdiskon;
diskon = total*20/100;
hdiskon = total - diskon;
TOTALBAYAR.setText("" + hdiskon);
}else {
TOTALBAYAR.setText(""+total);
}
}
private void TotalItemActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
int jumlahbelanja;
jumlahbelanja = ttv+tdvd+tsound+tradio+tmicrofon+tantena;
TotalItem.setText("" + jumlahbelanja);
}
private void nikActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
if(nik.getSelectedItem()=="Pilih"){
kasir.setText("");
}
else if(nik.getSelectedItem()=="161011400046"){
kasir.setText("Herlinda Mita M. Sitanggang");
}
else if(nik.getSelectedItem()=="161011400064"){
kasir.setText("Yuli Christiani Sitanggang");
}
else if(nik.getSelectedItem()=="161011400066"){
kasir.setText("Jhon M.A Sitanggang");
}
}
private void voucherActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
int jumlah1, jumlah2, jumlah3;
if (voucher.getSelectedItem()=="Voucher"){
TOTALBAYAR.setText(""+total);
}
if (voucher.getSelectedItem()=="V1"){
jumlah1=total-20000;
TOTALBAYAR.setText(""+jumlah1);
}
if (voucher.getSelectedItem()=="V2"){
jumlah2=total-50000;
TOTALBAYAR.setText(""+jumlah2);
}
if (voucher.getSelectedItem()=="V3"){
jumlah3=total-100000;
TOTALBAYAR.setText(""+jumlah3);
}
}
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
total = tv+dvd+sound+radio+microfon+antena;
TOTALBAYAR.setText(""+total);
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(UTSJFRAME.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(UTSJFRAME.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(UTSJFRAME.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(UTSJFRAME.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new UTSJFRAME().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton CARD;
private javax.swing.JRadioButton Diskon;
private javax.swing.JTextField HANTENA;
private javax.swing.JTextField HDVD;
private javax.swing.JTextField HMICROFON;
private javax.swing.JTextField HRADIO;
private javax.swing.JTextField HSOUND;
private javax.swing.JTextField HTV;
private javax.swing.JLabel Judul;
private javax.swing.JTextField JumlahAntena;
private javax.swing.JTextField JumlahDVD;
private javax.swing.JTextField JumlahMicrofon;
private javax.swing.JTextField JumlahRadio;
private javax.swing.JTextField JumlahSound;
private javax.swing.JTextField JumlahTV;
private javax.swing.JTextField TOTALBAYAR;
private javax.swing.JTextField TotalItem;
private javax.swing.JButton jButton1;
private javax.swing.JLabel jLabel10;
private javax.swing.JLabel jLabel11;
private javax.swing.JLabel jLabel12;
private javax.swing.JLabel jLabel13;
private javax.swing.JLabel jLabel14;
private javax.swing.JLabel jLabel15;
private javax.swing.JLabel jLabel16;
private javax.swing.JLabel jLabel17;
private javax.swing.JLabel jLabel18;
private javax.swing.JLabel jLabel19;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel20;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel8;
private javax.swing.JLabel jLabel9;
private javax.swing.JTextField jTextField6;
private javax.swing.JTextField kasir;
private javax.swing.JComboBox<String> nik;
private javax.swing.JComboBox<String> voucher;
// End of variables declaration
}
tekan Shift + F6
tampilannya seperti yang di bawah, setelah NIK di pilih, akan muncul nama nya secara otomatis.
kemudian input nominal item barang yang ingin di beli, kemudian tekan ENTER.
Dan harga normal dari semua barang yang di beli.
Dan jika belanja lebih besar, atau sama dengan Rp.3.000.000, maka akan mendapatkan Diskon 20%. Atau di klik tombol Disk 20% d layar. Dan tampilanny(Perubahan harga setelah diskon) seperti ini,
Dan jika pembayaran pakai Card akan ditambah diskon 5%. Stelah di diskon 5% tampilannya seperti ini (perubahan harga):
Dan jika ada Voucher, harga barang akan terpotong sesuai dengan nominal Voucher ya di berikan oleh costumer, misal menggunakan Voucher 50.000, maka di klik V2 d layar, maka tampilannya akan seperti ini:
Demikian Projek ini saya buat, lebih kurangnya mohon di maklumi.
Dan saya mengharapkan kritik dan saran dari teman-teman sekalian,
terimakasih.
No comments:
Post a Comment