Ya Teman - Teman Kali ini saya akan memberikan contoh tentang Aplikasi Parkir java sederhana yang pernah saya buat dengan menggunakan bahasa pemograman Java. Mungkin bagi temen - temen yang ingin mengembangkan project saya ini menjadi lebih baik lagi silakan saja.
classAplikasiParkirsederhana
package aplikasi.parkir.sederhana;
public class AplikasiParkirSederhana {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
Frame_Aplikasi_Parkir Laund = new Frame_Aplikasi_Parkir();
Laund.setVisible(true);
}
}
Class frame_Aplikasiparkir
package aplikasi.parkir.sederhana;
public class Frame_Aplikasi_Parkir extends javax.swing.JFrame {
/**
* Creates new form Frame_Aplikasi_Parkir
*/
public Frame_Aplikasi_Parkir() {
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() {
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("");
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("");
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) {
// TODO add your handling code here:
}
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) {
// 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_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>
/*
* Create and display the form
*/
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new Frame_Aplikasi_Parkir().setVisible(true);
}
});
}
// Variables declaration - do not modify
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
}
Dan Berikut Ini Design Tambilanya Gan
Terimakasih telah mengunjungi blog saya ini.
Pengunjung yg baik selalu ninggalin jejak :)
Salam Wani Sinau!
Tidak ada komentar:
Posting Komentar