Wednesday, July 2, 2008

Tugas Kuliah (Perpustakaan GUI)

Penjelasan Program Perpustakaan Sederhana

Berikut ini adalah tampilan Program Perpustakaan sederhana saat di Running / dijalankan

Pengoperasiannya :

  • Pastikan semua data harus diisi, jika tidak diisi akan terjadi error
  • Klik Pilih Jenis Buku untuk Jenis buku yang diinginkan, terdiri dari 3 pilihan yaitu Jenis Kamus, Jenis Majalah, Jenis TextBook
  • Masukkan judul buku yang dipinjam pada textbox yang disediakan
  • Masukkan tanggal peminjaman dengan format (tanggal-bulan-tahun) contoh : 02-02-2008
  • Masukkan tanggal pengembalian dengan format (tanggal-bulan-tahun) contoh : 05-02-2008
  • Masukkan jumlah hari denda pada textbox yang disediakan
  • Jika semua sudah diisi maka klik tombol Proses
  • Berikut sreenshoot untuk pengisian form

  • Berikut adalah screenshoot saat tombol Proses di klik yaitu menampilkan informasi peminjaman buku dan biaya yang harus dikeluarkan

Berikut ini Script program :

Main.java

/*

* To change this template, choose Tools | Templates

* and open the template in the editor.

*/

package perpustakaan;

/**

*

* @author CHAIRUL_M

*/

public class Main {

/**

* @param args the command line arguments

*/

public static void main(String[] args) {

// TODO code application logic here

}

}

Perpustakaan_Umun.java

/*

* PerpustakaanUmum.java

*

* Created on June 16, 2008, 10:12 AM

*/

package perpus;

/**

*

* @author CHAIRUL_M

*/

public class PerpustakaanUmum extends javax.swing.JFrame {

/** Creates new form PerpustakaanUmum */

public PerpustakaanUmum() {

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")

//

private void initComponents() {

jLabel1 = new javax.swing.JLabel();

jLabel2 = new javax.swing.JLabel();

jLabel3 = new javax.swing.JLabel();

jLabel4 = new javax.swing.JLabel();

jenisBuku = new javax.swing.JComboBox();

jLabel5 = new javax.swing.JLabel();

jLabel6 = new javax.swing.JLabel();

tanggal = new javax.swing.JTextField();

jLabel7 = new javax.swing.JLabel();

judulBuku = new javax.swing.JTextField();

jButton1 = new javax.swing.JButton();

hasilProses = new javax.swing.JLabel();

judulHasil = new javax.swing.JLabel();

jLabel10 = new javax.swing.JLabel();

tglKembali = new javax.swing.JTextField();

jLabel11 = new javax.swing.JLabel();

hariDenda = new javax.swing.JTextField();

hasilProses1 = new javax.swing.JLabel();

hasilProses2 = new javax.swing.JLabel();

hasilProses3 = new javax.swing.JLabel();

hasilProses4 = new javax.swing.JLabel();

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

setBackground(new java.awt.Color(102, 102, 102));

setState(2);

jLabel1.setFont(new java.awt.Font("Berlin Sans FB", 1, 24));

jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);

jLabel1.setText("Program Aplikasi Perpustakaan ");

jLabel2.setFont(new java.awt.Font("Tahoma", 1, 24));

jLabel2.setText("STTI Eresha Benarif ");

jLabel3.setIcon(new javax.swing.ImageIcon("C:\\programjava\\NetBeans\\Perpustakaan\\images\\books1.jpg")); // NOI18N

jLabel4.setFont(new java.awt.Font("Tahoma", 1, 14));

jLabel4.setText("Jl. H. Samali No.39 Jakarta Selatan");

jenisBuku.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Pilih Jenis Buku", "Jenis Kamus", "Jenis Majalah", "Jenis Text Book" }));

jenisBuku.addMouseListener(new java.awt.event.MouseAdapter() {

public void mouseClicked(java.awt.event.MouseEvent evt) {

jenisBukuMouseClicked(evt);

}

});

jenisBuku.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

jenisBukuActionPerformed(evt);

}

});

jLabel5.setFont(new java.awt.Font("Tahoma", 1, 12));

jLabel5.setText("Jenis Buku");

jLabel6.setFont(new java.awt.Font("Tahoma", 1, 12));

jLabel6.setText("Judul Buku");

tanggal.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

tanggalActionPerformed(evt);

}

});

jLabel7.setFont(new java.awt.Font("Tahoma", 1, 12));

jLabel7.setText("Tanggal Peminjaman");

jButton1.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N

jButton1.setText("Proses");

jButton1.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

jButton1ActionPerformed(evt);

}

});

judulHasil.setFont(new java.awt.Font("Arial Narrow", 1, 14)); // NOI18N

judulHasil.setForeground(new java.awt.Color(0, 0, 204));

jLabel10.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N

jLabel10.setText("Tanggal Pengembalian");

jLabel11.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N

jLabel11.setText("Jumlah Hari Denda");

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());

getContentPane().setLayout(layout);

layout.setHorizontalGroup(

layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(layout.createSequentialGroup()

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)

.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()

.addGap(42, 42, 42)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(layout.createSequentialGroup()

.addComponent(jButton1)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED))

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(layout.createSequentialGroup()

.addComponent(jLabel11)

.addGap(54, 54, 54)

.addComponent(hariDenda, javax.swing.GroupLayout.DEFAULT_SIZE, 155, Short.MAX_VALUE))

.addGroup(layout.createSequentialGroup()

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addComponent(jLabel5)

.addComponent(jLabel6)

.addComponent(jLabel10))

.addGap(31, 31, 31)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addComponent(tanggal, javax.swing.GroupLayout.DEFAULT_SIZE, 155, Short.MAX_VALUE)

.addComponent(tglKembali, javax.swing.GroupLayout.DEFAULT_SIZE, 155, Short.MAX_VALUE)

.addComponent(judulBuku, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 155, Short.MAX_VALUE)

.addComponent(jenisBuku, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))

.addGroup(layout.createSequentialGroup()

.addComponent(jLabel7)

.addGap(197, 197, 197))))

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(layout.createSequentialGroup()

.addGap(10, 10, 10)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addComponent(hasilProses1, javax.swing.GroupLayout.PREFERRED_SIZE, 265, javax.swing.GroupLayout.PREFERRED_SIZE)

.addComponent(hasilProses2, javax.swing.GroupLayout.DEFAULT_SIZE, 310, Short.MAX_VALUE)

.addComponent(hasilProses, javax.swing.GroupLayout.PREFERRED_SIZE, 289, javax.swing.GroupLayout.PREFERRED_SIZE)

.addComponent(judulHasil, javax.swing.GroupLayout.PREFERRED_SIZE, 205, javax.swing.GroupLayout.PREFERRED_SIZE)))

.addGroup(layout.createSequentialGroup()

.addGap(10, 10, 10)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addComponent(hasilProses4, javax.swing.GroupLayout.DEFAULT_SIZE, 310, Short.MAX_VALUE)

.addComponent(hasilProses3, javax.swing.GroupLayout.DEFAULT_SIZE, 310, Short.MAX_VALUE)))))

.addGroup(layout.createSequentialGroup()

.addComponent(jLabel3)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 155, Short.MAX_VALUE)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)

.addGroup(layout.createSequentialGroup()

.addComponent(jLabel4)

.addGap(6, 6, 6))

.addComponent(jLabel2)

.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 380, javax.swing.GroupLayout.PREFERRED_SIZE))))

.addContainerGap())

);

layout.setVerticalGroup(

layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(layout.createSequentialGroup()

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(layout.createSequentialGroup()

.addContainerGap()

.addComponent(jLabel1)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

.addComponent(jLabel2)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

.addComponent(jLabel4))

.addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 126, javax.swing.GroupLayout.PREFERRED_SIZE))

.addGap(68, 68, 68)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)

.addGroup(layout.createSequentialGroup()

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

.addComponent(jenisBuku, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)

.addComponent(jLabel5))

.addGap(15, 15, 15))

.addGroup(layout.createSequentialGroup()

.addComponent(judulHasil, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)

.addGap(18, 18, 18)))

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)

.addGroup(layout.createSequentialGroup()

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

.addComponent(jLabel6)

.addComponent(judulBuku, 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(jLabel7)

.addComponent(tanggal, 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(jLabel10)

.addComponent(tglKembali, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 3, Short.MAX_VALUE))

.addGroup(layout.createSequentialGroup()

.addComponent(hasilProses, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

.addComponent(hasilProses1, javax.swing.GroupLayout.PREFERRED_SIZE, 19, javax.swing.GroupLayout.PREFERRED_SIZE)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

.addComponent(hasilProses2, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)

.addGap(5, 5, 5)))

.addGap(0, 0, 0)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(layout.createSequentialGroup()

.addComponent(hasilProses3, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)

.addComponent(hasilProses4, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE))

.addGroup(layout.createSequentialGroup()

.addComponent(jLabel11)

.addGap(18, 18, 18)

.addComponent(jButton1))

.addComponent(hariDenda, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))

.addGap(42, 42, 42))

);

pack();

}//

private void jenisBukuActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here:

}

private void jenisBukuMouseClicked(java.awt.event.MouseEvent evt) {

// TODO add your handling code here:

}

private void tanggalActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here:

}

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here:

double hasil, hasil1, hasil2;

String jenis=jenisBuku.getSelectedItem().toString().toLowerCase();

String nama=judulBuku.getText();

String pinjam=tanggal.getText();

String kembali=tglKembali.getText();

int denda=(Integer.valueOf(hariDenda.getText()));

hasil=(3000 + (denda * 500));

hasil1=(1000 + (denda * 500));

hasil2=(2000 + (denda * 500));

if (jenis.equals("jenis kamus") && (denda >= 1)) {

judulHasil.setText("Hasil Proses Peminjaman");

hasilProses.setText("Jenis Buku adalah :\n " + jenis);

hasilProses1.setText("Judul Buku adalah :\n" + nama);

hasilProses2.setText("Tanggal Peminjaman Buku: \n" + pinjam);

hasilProses3.setText("Tanggal Pengembalian Buku: \n" + kembali);

hasilProses4.setText("Jumlah Pembayaran anda adalah : Rp.\n" + hasil);

}

else if (jenis.equals("jenis majalah") && (denda >= 1)){

judulHasil.setText("Hasil Proses Peminjaman");

hasilProses.setText("Jenis Buku adalah :\n " + jenis);

hasilProses1.setText("Judul Buku adalah :\n" + nama);

hasilProses2.setText("Tanggal Peminjaman Buku :\n" + pinjam);

hasilProses3.setText("Tanggal Pengembalian Buku :\n" + kembali);

hasilProses4.setText("Jumlah Pembayaran anda adalah :Rp.\n" + hasil1);

}

else

judulHasil.setText("Hasil Proses Peminjaman");

hasilProses.setText("Jenis Buku adalah :\n " + jenis);

hasilProses1.setText("Judul Buku adalah :\n" + nama);

hasilProses2.setText("Tanggal Peminjaman Buku :\n" + pinjam);

hasilProses3.setText("Tanggal Pengembalian Buku :\n" + kembali);

hasilProses4.setText("Jumlah Pembayaran anda adalah :Rp.\n" + hasil2);

}

/**

* @param args the command line arguments

*/

public static void main(String args[]) {

java.awt.EventQueue.invokeLater(new Runnable() {

public void run() {

new PerpustakaanUmum().setVisible(true);

}

});

}

// Variables declaration - do not modify

private javax.swing.JTextField hariDenda;

private javax.swing.JLabel hasilProses;

private javax.swing.JLabel hasilProses1;

private javax.swing.JLabel hasilProses2;

private javax.swing.JLabel hasilProses3;

private javax.swing.JLabel hasilProses4;

private javax.swing.JButton jButton1;

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.JComboBox jenisBuku;

private javax.swing.JTextField judulBuku;

private javax.swing.JLabel judulHasil;

private javax.swing.JTextField tanggal;

private javax.swing.JTextField tglKembali;

// End of variables declaration

}

No comments: