Assalamualaikum, . .
Kali ini saya akan membagikan tentang cara membuat aplikasi sederhana menggunakan java.
Pada zaman ini, dimana semuanya serba elektronik, maka banyak sekali terjadi kejahatan contohnya pencurian kendaraan bermotor dan biasanya terjadi di pusat perbelanjaan, perkantoran dll. sehingga keamanan pada saat memakir kendaraan menjadi hal yang sangat penting bagi pengunjung suatu instansi, sehingga saat ini banyak sekali instansi-instansi pusat perbelanjaan, kantor, perusahaan atau yang lainnya menggunakan sistem komputerisasi untuk proses parkir kerdaraan. Proses pendataan kendaraan yang semakin hari semakin canggih dengan memanfaatkan sistem komputer, memudahkan pemilik untuk memanajemen parkir dengan baik dan teratur. Selain kemudahan dan efisien, keamanan kendaraan yang di parkir terjamin karena kendaraan yang masuk maupun keluar telah tercatat dalam database sistem ini. Kemudahan ini yang mendorong semakin banyak pusat perbelanjaan dan perkantoran atau instansi beralih menggunakan sistem komputerisasi untuk mengatur parkir. Petugas parkir hanya melakukan input no kendaraaan dan jam masuk maka pengunjung akan mendapatkan resi parkir yang nantinya diberikan pada petugas ketika ingin keluar dari area parkir. Terinspirasi dari hal tersebut, Kami ingin mencoba membuat sebuah program parkir sederhana menggunakan Java.
Berikut adalah koding untuk membuat aplikasi parkir sederhana :
Bagian 1 adalah kelasnya
package aplikasi.parkir.sederhana;
public class AplikasiParkirSederhana {
public static void main(String[] args) {
// TODO code application logic here
Frame_Aplikasi_Parkir Laund = new Frame_Aplikasi_Parkir();
Laund.setVisible(true);
}
}
Bagian 2 adalah frame dari aplikasi
package aplikasi.parkir.sederhana;
public class Frame_Aplikasi_Parkir extends javax.swing.JFrame {
public Frame_Aplikasi_Parkir() {
initComponents();
}
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
jLabel7 = new javax.swing.JLabel();
NoKendaraan = new javax.swing.JTextField();
hargaParkir = new javax.swing.JTextField();
lamaParkir = new javax.swing.JTextField();
jamMasuk = new javax.swing.JTextField();
motor = new javax.swing.JRadioButton();
Mobil = new javax.swing.JRadioButton();
jLabel8 = new javax.swing.JLabel();
totalBayar = new javax.swing.JTextField();
jButton1 = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
jLabel9 = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setName(""); // NOI18N
jLabel1.setFont(new java.awt.Font("Arial", 1, 18)); // NOI18N
jLabel1.setText("Program Parkir Sederhana Serbabebas");
jLabel2.setFont(new java.awt.Font("Arial", 1, 14)); // NOI18N
jLabel2.setText("No. Kendaraan");
jLabel3.setFont(new java.awt.Font("Arial", 1, 14)); // NOI18N
jLabel3.setText("Jam Masuk");
jLabel4.setFont(new java.awt.Font("Arial", 1, 14)); // NOI18N
jLabel4.setText("Jenis Kendaraan");
jLabel5.setFont(new java.awt.Font("Arial", 1, 14)); // NOI18N
jLabel5.setText("Harga Parkir");
jLabel7.setFont(new java.awt.Font("Arial", 1, 14)); // NOI18N
jLabel7.setText("Lama Parkir");
NoKendaraan.setFont(new java.awt.Font("Arial", 1, 14)); // NOI18N
NoKendaraan.setName(""); // NOI18N
NoKendaraan.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
NoKendaraanActionPerformed(evt);
}
});
hargaParkir.setFont(new java.awt.Font("Arial", 1, 14)); // NOI18N
lamaParkir.setFont(new java.awt.Font("Arial", 1, 14)); // NOI18N
jamMasuk.setFont(new java.awt.Font("Arial", 1, 14)); // NOI18N
jamMasuk.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jamMasukActionPerformed(evt);
}
});
motor.setText("Motor");
motor.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
motorActionPerformed(evt);
}
});
Mobil.setText("Mobil");
Mobil.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
MobilActionPerformed(evt);
}
});
jLabel8.setFont(new java.awt.Font("Arial", 1, 14)); // NOI18N
jLabel8.setText("Total Bayar");
totalBayar.setFont(new java.awt.Font("Arial", 1, 14)); // NOI18N
totalBayar.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
totalBayarActionPerformed(evt);
}
});
jButton1.setText("Proses");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
jButton2.setText("Clear");
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});
jLabel9.setFont(new java.awt.Font("Arial", 1, 14)); // NOI18N
jLabel9.setText("Jam");
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(36, 36, 36)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel1)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(jLabel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addComponent(jLabel4)
.addComponent(jLabel5)
.addComponent(jLabel7))
.addGap(58, 58, 58)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(hargaParkir)
.addComponent(NoKendaraan)
.addComponent(jamMasuk)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(motor)
.addGap(18, 18, 18)
.addComponent(Mobil))
.addGroup(layout.createSequentialGroup()
.addComponent(lamaParkir, javax.swing.GroupLayout.PREFERRED_SIZE, 52, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel9)))
.addGap(0, 0, Short.MAX_VALUE))))
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel8)
.addGap(99, 99, 99)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jButton1)
.addGap(18, 18, 18)
.addComponent(jButton2))
.addComponent(totalBayar)))))
.addContainerGap(23, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 47, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(26, 26, 26)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(NoKendaraan, 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.BASELINE)
.addComponent(jLabel4)
.addComponent(motor)
.addComponent(Mobil))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel5)
.addComponent(hargaParkir, 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(jamMasuk, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel3))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(lamaParkir, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel7)
.addComponent(jLabel9))
.addGap(51, 51, 51)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jButton1)
.addComponent(jButton2))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(totalBayar, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel8))
.addContainerGap(33, Short.MAX_VALUE))
);
pack();
}// </editor-fold>
private void totalBayarActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void motorActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
hargaParkir.setText("2000");
jamMasuk.setText("07.00 WIB");
}
private void NoKendaraanActionPerformed(java.awt.event.ActionEvent evt) {
}
private void MobilActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
hargaParkir.setText("5000");
jamMasuk.setText("07.00 WIB");
}
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
int c = Integer.parseInt(hargaParkir.getText());
int d = Integer.parseInt(lamaParkir.getText());
int hasilnya = c*d;
totalBayar.setText(""+hasilnya);
}
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
NoKendaraan.setText("");
jamMasuk.setText("");
lamaParkir.setText("");
hargaParkir.setText("");
totalBayar.setText("");
motor.setSelected(false);
Mobil.setSelected(false);
motor.setEnabled(true);
Mobil.setEnabled(true);
}
private void jamMasukActionPerformed(java.awt.event.ActionEvent evt) {
}
public static void main(String args[]) {
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_Aplikasi_Parkir.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(Frame_Aplikasi_Parkir.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(Frame_Aplikasi_Parkir.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(Frame_Aplikasi_Parkir.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new Frame_Aplikasi_Parkir().setVisible(true);
}
});
}
// Jangan di modifikasi
private javax.swing.JRadioButton Mobil;
private javax.swing.JTextField NoKendaraan;
private javax.swing.JTextField hargaParkir;
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel8;
private javax.swing.JLabel jLabel9;
private javax.swing.JTextField jamMasuk;
private javax.swing.JTextField lamaParkir;
private javax.swing.JRadioButton motor;
private javax.swing.JTextField totalBayar;
// End of variables declaration
}
Berikut output dari program dia atas :
Semoga bermanfaat . .
0 Response to "Aplikasi Parkir Sederhana"
Post a Comment