MEMBUAT APLIKASI SWING GUI
LAUNDRY
Bila anda tertarik membuka bisnis jasa
laundry, anda dapat menjalankannya dengan lebih kreatif, misalnya:
dengan menerapkan pemesanan jasa maupun pembayaran secara komputerisasi.
Dengan cara tersebut tentu akan lebih efisien dan bisnis dapat dikelola
dengan mudah. Sistem komputerisasi dapat berupa program sederhana yang
dibuat menggunakan software atau yang lainnya. Terinspirasi dari hal
tersebut, penulis mencoba untuk membuat sebuah program sederhana untuk
laundry menggunakan Java NetBeans, berikut ini ulasannya :
Preview Design
Penjelasan
Adapun Variables declaration yang dibutuhkan :
private javax.swing.JButton btnBersih;
private javax.swing.JButton btnClear;
private javax.swing.JButton btnTampil;
private javax.swing.ButtonGroup buttonGroup1;
private javax.swing.JCheckBox chxBad;
private javax.swing.JCheckBox chxKarpet;
private javax.swing.JComboBox cmbJenis;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel10;
private javax.swing.JLabel jLabel11;
private javax.swing.JLabel jLabel2;
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.JScrollPane jScrollPane1;
private javax.swing.JRadioButton rbTidak;
private javax.swing.JRadioButton rbYa;
private javax.swing.JTextArea taOut;
private javax.swing.JTextField txtAlamat;
private javax.swing.JTextField txtBad;
private javax.swing.JTextField txtHarga;
private javax.swing.JTextField txtJumlah;
private javax.swing.JTextField txtKarpet;
private javax.swing.JTextField txtNama;
private javax.swing.JTextField txtNoTransaksi;
private javax.swing.JTextField txtTotal;
private javax.swing.JButton btnBersih;
private javax.swing.JButton btnClear;
private javax.swing.JButton btnTampil;
private javax.swing.ButtonGroup buttonGroup1;
private javax.swing.JCheckBox chxBad;
private javax.swing.JCheckBox chxKarpet;
private javax.swing.JComboBox cmbJenis;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel10;
private javax.swing.JLabel jLabel11;
private javax.swing.JLabel jLabel2;
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.JScrollPane jScrollPane1;
private javax.swing.JRadioButton rbTidak;
private javax.swing.JRadioButton rbYa;
private javax.swing.JTextArea taOut;
private javax.swing.JTextField txtAlamat;
private javax.swing.JTextField txtBad;
private javax.swing.JTextField txtHarga;
private javax.swing.JTextField txtJumlah;
private javax.swing.JTextField txtKarpet;
private javax.swing.JTextField txtNama;
private javax.swing.JTextField txtNoTransaksi;
private javax.swing.JTextField txtTotal;
- No. Nota, Nama Pelanggan, dan Alamat merupakan data pelanggan.
- Jenis Laundry merupakan jenis jasa cuci yang dapat dipilih dengan ketentuan harga yang telah ditentukan dan dikali dengan berat order.
- Tambahan merupakan jenis jasa laundry untuk menambahkan order yang tidak ada pada item jenis laundry.
- Hasil output merupakan hasil print out dari data entri.
- Button bersih merupakan tombol untuk membersihkan/refresh data yang sudah diinput agar dapat menginput data baru.
- Button keluar untuk keluar dari aplikasi,
- Button tampil untuk menampilkan hasil print out pada item hasil output
Source Code
private void chxBadActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
if (chxBad.isSelected()){
bad=20000;
}
txtBad.setText(String.valueOf(bad));
ckr=Integer.parseInt(txtHarga.getText());
int karpet1=Integer.parseInt(txtKarpet.getText());
int bad1=Integer.parseInt(txtBad.getText());
jumlah=Integer.parseInt(txtJumlah.getText());
totalbayar=karpet1+bad1+(ckr*jumlah);
txtTotal.setText(String.valueOf(totalbayar));
}
{
bad=0;
}
// TODO add your handling code here:
if (chxBad.isSelected()){
bad=20000;
}
txtBad.setText(String.valueOf(bad));
ckr=Integer.parseInt(txtHarga.getText());
int karpet1=Integer.parseInt(txtKarpet.getText());
int bad1=Integer.parseInt(txtBad.getText());
jumlah=Integer.parseInt(txtJumlah.getText());
totalbayar=karpet1+bad1+(ckr*jumlah);
txtTotal.setText(String.valueOf(totalbayar));
}
{
bad=0;
}
private void chxKarpetActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
if (chxKarpet.isSelected()){
karpet=25000;
txtKarpet.setText(String.valueOf(karpet));
ckr=Integer.parseInt(txtHarga.getText());
int karpet1=Integer.parseInt(txtKarpet.getText());
int bad1=Integer.parseInt(txtBad.getText());
jumlah=Integer.parseInt(txtJumlah.getText());
totalbayar=karpet1+bad1+(ckr*jumlah);
txtTotal.setText(String.valueOf(totalbayar));
}karpet=0;
}
// TODO add your handling code here:
if (chxKarpet.isSelected()){
karpet=25000;
txtKarpet.setText(String.valueOf(karpet));
ckr=Integer.parseInt(txtHarga.getText());
int karpet1=Integer.parseInt(txtKarpet.getText());
int bad1=Integer.parseInt(txtBad.getText());
jumlah=Integer.parseInt(txtJumlah.getText());
totalbayar=karpet1+bad1+(ckr*jumlah);
txtTotal.setText(String.valueOf(totalbayar));
}karpet=0;
}
private void chxKarpetActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
if (chxKarpet.isSelected()){
karpet=25000;
txtKarpet.setText(String.valueOf(karpet));
ckr=Integer.parseInt(txtHarga.getText());
int karpet1=Integer.parseInt(txtKarpet.getText());
int bad1=Integer.parseInt(txtBad.getText());
jumlah=Integer.parseInt(txtJumlah.getText());
totalbayar=karpet1+bad1+(ckr*jumlah);
txtTotal.setText(String.valueOf(totalbayar));
}karpet=0;
}
// TODO add your handling code here:
if (chxKarpet.isSelected()){
karpet=25000;
txtKarpet.setText(String.valueOf(karpet));
ckr=Integer.parseInt(txtHarga.getText());
int karpet1=Integer.parseInt(txtKarpet.getText());
int bad1=Integer.parseInt(txtBad.getText());
jumlah=Integer.parseInt(txtJumlah.getText());
totalbayar=karpet1+bad1+(ckr*jumlah);
txtTotal.setText(String.valueOf(totalbayar));
}karpet=0;
}
private void cmbJenisActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
if (cmbJenis.getSelectedItem().equals("Express")){
txtHarga.setText("10000");
ckr=Integer.parseInt(txtHarga.getText());
jumlah=Integer.parseInt(txtJumlah.getText());
totalbayar=ckr*jumlah+bad+karpet;
txtTotal.setText(String.valueOf(totalbayar));
}else
if (cmbJenis.getSelectedItem().equals("Regular")){
txtHarga.setText("5000");
ckr=Integer.parseInt(txtHarga.getText());
jumlah=Integer.parseInt(txtJumlah.getText());
totalbayar=ckr*jumlah+bad+karpet;
txtTotal.setText(String.valueOf(totalbayar));
}
}
// TODO add your handling code here:
if (cmbJenis.getSelectedItem().equals("Express")){
txtHarga.setText("10000");
ckr=Integer.parseInt(txtHarga.getText());
jumlah=Integer.parseInt(txtJumlah.getText());
totalbayar=ckr*jumlah+bad+karpet;
txtTotal.setText(String.valueOf(totalbayar));
}else
if (cmbJenis.getSelectedItem().equals("Regular")){
txtHarga.setText("5000");
ckr=Integer.parseInt(txtHarga.getText());
jumlah=Integer.parseInt(txtJumlah.getText());
totalbayar=ckr*jumlah+bad+karpet;
txtTotal.setText(String.valueOf(totalbayar));
}
}
private void btnBersihActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
txtNoTransaksi.setText("");
txtNama.setText("");
txtAlamat.setText("");
txtJumlah.setText("");
txtHarga.setText("");
txtTotal.setText("");
txtKarpet.setText("");
txtBad.setText("");
taOut.setText("");
rbYa.setSelected(false);
rbTidak.setSelected(false);
cmbJenis.setSelectedIndex(0);
chxKarpet.setSelected(false);
chxBad.setSelected(false);
JOptionPane.showMessageDialog(null,"screen udah dibersihkan","Information",JOptionPane.INFORMATION_MESSAGE);
}
// TODO add your handling code here:
txtNoTransaksi.setText("");
txtNama.setText("");
txtAlamat.setText("");
txtJumlah.setText("");
txtHarga.setText("");
txtTotal.setText("");
txtKarpet.setText("");
txtBad.setText("");
taOut.setText("");
rbYa.setSelected(false);
rbTidak.setSelected(false);
cmbJenis.setSelectedIndex(0);
chxKarpet.setSelected(false);
chxBad.setSelected(false);
JOptionPane.showMessageDialog(null,"screen udah dibersihkan","Information",JOptionPane.INFORMATION_MESSAGE);
}
private void btnClearActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
this.setVisible(false);
System.exit(0);
}
// TODO add your handling code here:
this.setVisible(false);
System.exit(0);
}
private void btnTampilActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
taOut.setText(
"No. Nota :\n"
+ " "+txtNoTransaksi.getText()+"\n"+
"Nama Pelanggan :\n"
+ " "+txtNama.getText()+"\n"+
"Alamat :\n"
+ " "+txtAlamat.getText()+"\n"+
"Jenis Laundry :\n"
+ " "+cmbJenis.getSelectedItem()+"\n"+
"Berat :\n"
+" "+txtJumlah.getText()+"\n"+
"Total Harga :\n "+txtTotal.getText()+"\n");
}
// TODO add your handling code here:
taOut.setText(
"No. Nota :\n"
+ " "+txtNoTransaksi.getText()+"\n"+
"Nama Pelanggan :\n"
+ " "+txtNama.getText()+"\n"+
"Alamat :\n"
+ " "+txtAlamat.getText()+"\n"+
"Jenis Laundry :\n"
+ " "+cmbJenis.getSelectedItem()+"\n"+
"Berat :\n"
+" "+txtJumlah.getText()+"\n"+
"Total Harga :\n "+txtTotal.getText()+"\n");
}
Demikian ulasannya, semoga bisa menjadi manfaat...
Salam,
Tidak ada komentar:
Posting Komentar