Bisnis warnet atau warung internet memang cukup mudah Kita temui diberbagai tempat. Hal ini karena cukup banyak pebisnis yang membuka jasa warnet. Kebanyakan orang menghabiskan waktunya di warnet hanya untuk bermain game, streaming video, chatting dan lain sebagainya. Namun jasa warnet saat ini penggemarnya mulai menurun karena kini semakin mudahnya orang untuk mengakses internet melalui Smartphone. Walaupun demikian warnet tetap banyak pengunjung yang datang mulai dari anak kecil hingga dewasa, maka tak jarang pula setiap hari warnet selalu penuh pengunjung hingga malam hari. Pada jasa warnet biasanya terdapat billing untuk mencatat waktu client atau user menggunakan Komputer. Pada sistem billing, pemilik warnet sebagai operator yang bertugas mengelola warnet, mengontrol keuangan, melihat data member warnet dan lain sebagainya. Penggunaan billing pada warnet memang sangat diperlukan, untuk itu Kami mencoba membuat sebuah program sederhana billing warnet menggunakan Java NetBeans. Berikut ini tahapan pembuatan program billing warnet:
1. Buat project baru pada software NetBeans
Anda dapat membuat program billing warnet sederhana menggunakan software NetBeans. Jika software telah dijalankan, pilih File > New Project untuk membuat sebuah project baru seperti gambar berikut ini.
Anda dapat membuat program billing warnet sederhana menggunakan software NetBeans. Jika software telah dijalankan, pilih File > New Project untuk membuat sebuah project baru seperti gambar berikut ini.
Selanjutnya pembuatan script pemrograman java pada class ProgramSederhanaBillingWarnet.
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package program.sederhana.billing.warnet;
/**
*
* @Gita_fitriani
*/
public class ProgramSederhanaBillingWarnet {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
Frame_billing_warnet Laund = new Frame_billing_warnet();
Laund.setVisible(true);
}
}
Buat frame baru untuk mempilkan hasil program dalam sebuah form. Buat frame dengan cara klik kanan pada package > New > JFrame Form dengan nama Frame_billing_warnet. Berikut ini contoh cara pembuatan frame baru.
Desain frame sesuai keinginan Anda atau dapat melihat contoh desain yang telah Kami buat.
Selanjutnya pembuatan script pemrograman java pada frame dengan cara klik kanan pada button Hitung > Events > Actions > ActionPerformed.
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package program.sederhana.billing.warnet;
/**
*
@Gita_fitriani
*/
public class Frame_billing_warnet extends javax.swing.JFrame {
/**
* Creates new form Frame_billing_warnet
*/
public Frame_billing_warnet() {
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() {
buttonGroup1 = new javax.swing.ButtonGroup();
jLabel3 = new javax.swing.JLabel();
jLabel8 = new javax.swing.JLabel();
Kom1 = new javax.swing.JRadioButton();
Kom2 = new javax.swing.JRadioButton();
Kom3 = new javax.swing.JRadioButton();
jLabel5 = new javax.swing.JLabel();
txtBiaya = new javax.swing.JTextField();
jLabel6 = new javax.swing.JLabel();
txtWaktu = new javax.swing.JTextField();
jLabel7 = new javax.swing.JLabel();
txtLainnya = new javax.swing.JTextField();
btnHitung = new javax.swing.JButton();
txtBayar = new javax.swing.JTextField();
jLabel1 = new javax.swing.JLabel();
Kom4 = new javax.swing.JRadioButton();
Kom5 = new javax.swing.JRadioButton();
Kom6 = new javax.swing.JRadioButton();
jButton1 = new javax.swing.JButton();
jScrollPane1 = new javax.swing.JScrollPane();
jTextArea1 = new javax.swing.JTextArea();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jLabel3.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
jLabel3.setText("Total Bayar");
jLabel8.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
jLabel8.setText("No Komputer");
buttonGroup1.add(Kom1);
Kom1.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
Kom1.setText("Kom 1");
Kom1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
Kom1ActionPerformed(evt);
}
});
buttonGroup1.add(Kom2);
Kom2.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
Kom2.setText("Kom 2");
Kom2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
Kom2ActionPerformed(evt);
}
});
buttonGroup1.add(Kom3);
Kom3.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
Kom3.setText("Kom 3");
Kom3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
Kom3ActionPerformed(evt);
}
});
jLabel5.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
jLabel5.setText("Biaya Per Jam");
txtBiaya.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
jLabel6.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
jLabel6.setText("Lama Penggunaan");
txtWaktu.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
jLabel7.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
jLabel7.setText("Pesanan Lain (Snack)");
txtLainnya.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
btnHitung.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
btnHitung.setText("Hitung");
btnHitung.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnHitungActionPerformed(evt);
}
});
txtBayar.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
jLabel1.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
jLabel1.setText("GITA.NET");
buttonGroup1.add(Kom4);
Kom4.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
Kom4.setText("Kom 4");
Kom4.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
Kom4ActionPerformed(evt);
}
});
buttonGroup1.add(Kom5);
Kom5.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
Kom5.setText("Kom 5");
Kom5.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
Kom5ActionPerformed(evt);
}
});
buttonGroup1.add(Kom6);
Kom6.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
Kom6.setText("Kom 6");
Kom6.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
Kom6ActionPerformed(evt);
}
});
jButton1.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
jButton1.setText("Keluar");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
jTextArea1.setColumns(20);
jTextArea1.setRows(5);
jTextArea1.setText("Nama\t: Gita Fitriani\nNIM\t: 1610 1140 1381\nMK\t: Algoritma Pemrograman\nJurusan\t: Teknik Informatika\nTugas\t: UAS");
jScrollPane1.setViewportView(jTextArea1);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(22, 22, 22)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 104, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel8))
.addGap(53, 53, 53)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addGroup(layout.createSequentialGroup()
.addComponent(Kom1)
.addGap(18, 18, 18)
.addComponent(Kom2))
.addComponent(txtBiaya)
.addComponent(txtWaktu)))
.addComponent(jLabel6)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 293, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(Kom3)
.addGap(18, 18, 18)
.addComponent(Kom4)
.addGap(18, 18, 18)
.addComponent(Kom5)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 2, Short.MAX_VALUE)
.addComponent(Kom6)
.addGap(12, 12, 12))
.addComponent(jButton1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(btnHitung, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel7)
.addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 104, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(11, 11, 11)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(txtBayar)
.addComponent(txtLainnya))))))
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(43, 43, 43)
.addComponent(jLabel1)
.addGap(36, 36, 36)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel8)
.addComponent(Kom1)
.addComponent(Kom3)
.addComponent(Kom2)
.addComponent(Kom4)
.addComponent(Kom5)
.addComponent(Kom6))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel5)
.addComponent(txtBiaya, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel7)
.addComponent(txtLainnya, 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)
.addComponent(jLabel6)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(txtWaktu, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel3)
.addComponent(txtBayar, 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.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(0, 0, Short.MAX_VALUE)
.addComponent(btnHitung)
.addGap(30, 30, 30)
.addComponent(jButton1))
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 149, Short.MAX_VALUE))
.addContainerGap())
);
pack();
}// </editor-fold>
private void Kom1ActionPerformed(java.awt.event.ActionEvent evt) {
// // TODO add your handling code here:
txtBiaya.setText("3000");
}
private void Kom2ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
txtBiaya.setText("3000");
}
private void Kom3ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
txtBiaya.setText("3000");
}
private void btnHitungActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
int a = Integer.parseInt(txtBiaya.getText());
int b = Integer.parseInt(txtWaktu.getText());
int c = Integer.parseInt(txtLainnya.getText());
int hasilnya = a * b + c;
txtBayar.setText("" + hasilnya);
}
private void Kom4ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
txtBiaya.setText("3000");
}
private void Kom5ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
txtBiaya.setText("3000");
}
private void Kom6ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
txtBiaya.setText("3000");
}
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
//exit
dispose ();
// TODO add your handling code here:
}
/**
* @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(Frame_billing_warnet.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(Frame_billing_warnet.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(Frame_billing_warnet.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(Frame_billing_warnet.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 Frame_billing_warnet().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JRadioButton Kom1;
private javax.swing.JRadioButton Kom2;
private javax.swing.JRadioButton Kom3;
private javax.swing.JRadioButton Kom4;
private javax.swing.JRadioButton Kom5;
private javax.swing.JRadioButton Kom6;
private javax.swing.JButton btnHitung;
private javax.swing.ButtonGroup buttonGroup1;
private javax.swing.JButton jButton1;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel3;
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.JTextArea jTextArea1;
private javax.swing.JTextField txtBayar;
private javax.swing.JTextField txtBiaya;
private javax.swing.JTextField txtLainnya;
private javax.swing.JTextField txtWaktu;
// End of variables declaration
}
2. Lihat hasil program billing warnet
Jalankan hasil program billing warnet dengan memilih Run Main Project(F6) atau Pilih Project > Klik kanan > Run. Pada program tersebut, Anda dapat memilih no komputer dan melakukan input lama penggunaan dan pesanan lain (snack). Pilih button Hitung maka akan muncul total biaya yang harus dibayar.
Jalankan hasil program billing warnet dengan memilih Run Main Project(F6) atau Pilih Project > Klik kanan > Run. Pada program tersebut, Anda dapat memilih no komputer dan melakukan input lama penggunaan dan pesanan lain (snack). Pilih button Hitung maka akan muncul total biaya yang harus dibayar.
Sangatt membantu, Terimakasih banyakk
BalasHapus