APLIKASI PENJUALAN SENJATA
Assalamu’alaikum Wr. Wb.
Pada kesempatan kali ini, saya telah membuat project
Java berbasis Swing GUI dengan menggunakan NetBeans IDE 8.2. Aplikasi ini
dibuat untuk mempermudah pemilik toko senjata dalam menentukan pembayaran kepada
pelanggannya. Dimana inputnya terdiri dari Nama Senjata, Asal
Senjata, Tipe Senjata, dan Harga Senjata. Lalu outputnya terdiri dari Harga,
Diskon, dan Total Bayar. Aplikasi ini hanya menggunakan beberapa komponen saja,
yaitu Label, Text Field, Button, Radio Button, dan Check Box.
Penjelasan:
- Radio Button berfungsi untuk memilih jenis senjata yang ingin dibeli.
- Check Box “Diskon” berfungsi untuk memberikan diskon jika pembelian senjata di atas $3000.
- Text Field berfungsi untuk menampilkan hasil yang berasal dari Radio Button, Button dan Check Box.
- Button “Harga” berfungsi untuk menjumlahkan harga dari pembelian senjata utama dan senjata kedua.
- Button “Total Bayar” berfungsi untuk menjumlahkan total pembayaran.
- Button “CLEAR” berfungsi untuk menghapus hasil output yang berada di Text Field.
- Button “EXIT” berfungsi untuk menutup aplikasi tersebut.
Source Code:
Source Code “Radio Button” Senjata Utama
private void
RB1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
TFNama.setText(""+RB1.getText());
TFTipe.setText("Shotgun");
TFAsal.setText("Italia");
TFHarga.setText(""+1700);
}
private void
RB2ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
TFNama.setText(""+RB2.getText());
TFTipe.setText("Shotgun");
TFAsal.setText("Italia");
TFHarga.setText(""+3000);
}
private void
RB3ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
TFNama.setText(""+RB3.getText());
TFTipe.setText("SMG");
TFAsal.setText("Amerika");
TFHarga.setText(""+1400);
}
private void
RB4ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
TFNama.setText(""+RB4.getText());
TFTipe.setText("SMG");
TFAsal.setText("Austria");
TFHarga.setText(""+1250);
}
private void
RB5ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
TFNama.setText(""+RB5.getText());
TFTipe.setText("SMG");
TFAsal.setText("Jerman");
TFHarga.setText(""+1500);
}
private void
RB6ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
TFNama.setText(""+RB6.getText());
TFTipe.setText("SMG");
TFAsal.setText("Jerman");
TFHarga.setText(""+1700);
}
private void
RB7ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
TFNama.setText(""+RB7.getText());
TFTipe.setText("SMG");
TFAsal.setText("Belgia");
TFHarga.setText(""+2350);
}
private void
RB8ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
TFNama.setText(""+RB8.getText());
TFTipe.setText("Rifle");
TFAsal.setText("Israel");
TFHarga.setText(""+2000);
}
private void
RB9ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
TFNama.setText(""+RB9.getText());
TFTipe.setText("Rifle");
TFAsal.setText("Perancis");
TFHarga.setText(""+2250);
}
private void
RB10ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
TFNama.setText(""+RB10.getText());
TFTipe.setText("Rifle");
TFAsal.setText("Rusia");
TFHarga.setText(""+2500);
}
private void
RB11ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
TFNama.setText(""+RB11.getText());
TFTipe.setText("Rifle");
TFAsal.setText("Amerika");
TFHarga.setText(""+3100);
}
private void
RB12ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
TFNama.setText(""+RB12.getText());
TFTipe.setText("Rifle");
TFAsal.setText("Swiss");
TFHarga.setText(""+3500);
}
private void
RB13ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
TFNama.setText(""+RB13.getText());
TFTipe.setText("Rifle");
TFAsal.setText("Austria");
TFHarga.setText(""+3500);
}
private void
RB14ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
TFNama.setText(""+RB14.getText());
TFTipe.setText("Sniper");
TFAsal.setText("Jerman");
TFHarga.setText(""+5000);
}
private void
RB15ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
TFNama.setText(""+RB15.getText());
TFTipe.setText("Sniper");
TFAsal.setText("Swiss");
TFHarga.setText(""+4200);
}
private void
RB16ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
TFNama.setText(""+RB16.getText());
TFTipe.setText("Sniper");
TFAsal.setText("Austria");
TFHarga.setText(""+2750);
}
private void
RB17ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
TFNama.setText(""+RB17.getText());
TFTipe.setText("Sniper");
TFAsal.setText("Inggris");
TFHarga.setText(""+4750);
}
private void
RB18ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
TFNama.setText(""+RB18.getText());
TFTipe.setText("Machine
Gun");
TFAsal.setText("Belgia");
TFHarga.setText(""+5750);
}
Source Code “Radio Button” Senjata Kedua
private void
RB19ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
TFNama2.setText(""+RB19.getText());
TFHarga2.setText(""+400);
}
private void
RB20ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
TFNama2.setText(""+RB20.getText());
TFHarga2.setText(""+500);
}
private void
RB21ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
TFNama2.setText(""+RB21.getText());
TFHarga2.setText(""+600);
}
private void
RB22ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
TFNama2.setText(""+RB22.getText());
TFHarga2.setText(""+650);
}
private void
RB23ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
TFNama2.setText(""+RB23.getText());
TFHarga2.setText(""+800);
}
private void RB24ActionPerformed(java.awt.event.ActionEvent
evt) {
// TODO add your handling code here:
TFNama2.setText(""+RB24.getText());
TFHarga2.setText(""+750);
}
Source Code “Button” Harga
private void
jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
int H1 =
Integer.parseInt(TFHarga.getText());
int H2 =
Integer.parseInt(TFHarga2.getText());
int Total = H1+H2;
TFTotalHarga.setText(""+Total);
}
Source Code “Check Box” Diskon 10%
private void
CBDiskonActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
if(CBDiskon.isSelected())
{
int TH =
Integer.parseInt(TFTotalHarga.getText());
int Diskon = TH/10;
TFDiskon.setText(""+Diskon);
}
else
{
TFDiskon.setText(""+0);
}
}
Source Code “Button” Total Bayar
private void
jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
int H1 =
Integer.parseInt(TFTotalHarga.getText());
int H2 = Integer.parseInt(TFDiskon.getText());
int Total = H1-H2;
TFTotalBayar.setText("$"+Total);
}
Source Code “Button” CLEAR
private void
jButton3ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
TFNama.setText("");
TFNama2.setText("");
TFHarga.setText("");
TFHarga2.setText("");
TFAsal.setText("");
TFTipe.setText("");
TFDiskon.setText("");
TFTotalHarga.setText("");
TFTotalBayar.setText("");
}
Source Code “Button” EXIT
private void
jButton4ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
this.dispose();
}
Wassalamu'alaikum Wr. Wb.


Komentar
Posting Komentar