Dan untuk tugas kali ini saya membuat 3 JFrame Form.
Berikut desain yang sudah jadi
"LOGIN"
"DATA MOBIL"
"DATA PEMINJAM"
Dan ini source code dari desain LOGIN :
private void okActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
String user = "chantika";
String pas = "widias";
String username = usser.getText();
String pasword = pass.getText();
if (username.equals(user) && pasword.equals(pas)) {
this.setVisible(false);
new DataMobil().setVisible(true);
} else {
javax.swing.JOptionPane.showMessageDialog(null, "Maaf user atau "
+ "password anda salah");
usser.setText("");
pass.setText("");
usser.requestFocus();
}
}
Untuk coding data mobil, setiap gambar terdapat codingan.
Coding DATA MOBIL :
private void acActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
ac.isSelected();
}
Coding di button SIMPAN :
private void simpanActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
new DataPeminjam().show();
}
Coding di button HAPUS :
private void hapusActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
a1.setText(" ");
a2.setText(" ");
a3.setText(" ");
b1.setText(" ");
b2.setText(" ");
b3.setText(" ");
c1.setText(" ");
c2.setText(" ");
c3.setText(" ");
ac.setSelected(false);
tvd.setSelected(false);
dongkrak.setSelected(false);
ban.setSelected(false);
pengharum.setSelected(false);
p3k.setSelected(false);
}
private void formWindowActivated(java.awt.event.WindowEvent evt) {
// TODO add your handling code here:
}
private void tvdActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
tvd.isSelected();
}
private void pengharumActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
pengharum.isSelected();
}
private void dongkrakActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
dongkrak.isSelected();
}
private void banActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
ban.isSelected();
}
private void p3kActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
p3k.isSelected();
}
Coding yang terdapat digambar :
private void avanzaMouseClicked(java.awt.event.MouseEvent evt) {
// TODO add your handling code here:
a1.setText("001");
b1.setText("AVANZA");
c1.setText("Rp 500.000 / hari");
}
private void inovaMouseClicked(java.awt.event.MouseEvent evt) {
// TODO add your handling code here:
a2.setText("002");
b2.setText("INOVA");
c2.setText("Rp 550.000 / hari");
}
private void ertigaMouseClicked(java.awt.event.MouseEvent evt) {
// TODO add your handling code here:
a3.setText("001");
b3.setText("ERTIGA");
c3.setText("Rp 600.000 / hari");
}
Dan ini terdapat codingan terakhir di JFrame Form DATA PEMINJAM :
Coding yang terdapat di button Simpan
private void simpanActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
JOptionPane.showMessageDialog(rootPane,"Data Tesimpan");
}
Coding yang terdapat di button Keluar
private void keluarActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
if (JOptionPane.showConfirmDialog(null,
"Anda Yakin?","Confirmation Dialog",
JOptionPane.YES_NO_OPTION)==
JOptionPane.YES_OPTION){
System.exit(0);
}
}
Coding yang terdapat di button Hapus
private void hapusActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
nama.setText(" ");
pria.setSelected(false);
wanita.setSelected(false);
alamat.setText(" ");
hari.setText(" ");
tarif.setText(" ");
total.setText(" ");
hp.setText(" ");
}
Coding yang terdapat di button Hitung
private void hitungActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
int a1 = Integer.parseInt(tarif.getText());
int a2 = Integer.parseInt(hari.getText());
int total1 = a1*a2;
total.setText(" "+total1);
}
Hasil RUN