Studi Informatika

Panduan Pembelajaran Ilmu Teknologi & Komputer

Sunday, July 29, 2018

MEMBUAT APLIKASI PENYEWAAN LAPANGAN FUTSAL MENGGUNAKAN JAVA NETBEANS

Tahap pertama dalam membuat aplikasi penyewaan lapangan futsal menggunakan java netbeans yaitu:
1. buka dulu aplikasi netbeansnya
2. buka new projet dan beri nama source peckages : booking_lapangan_futsal (bisa diubah sendiri)
3. buat dua java class : class yang pertama namanya : BookingLapanganFutsal dan berikut isi kodingnya :

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package booking_lapangan_futsal;

/**
 *
 * @author Ardy Sendleep
 */
public class BookingLapanganFutsal {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
       
        Frame_booking_lapangan Laund = new Frame_booking_lapangan();
        Laund.setVisible(true);
    }
}

4. buat class kedua dan ini isi codingnya :

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package booking_lapangan_futsal;

import javax.swing.table.DefaultTableModel;

/**
 *
 * @author Ardy Sendleep
 */
public class Model_booking {

 
    private DefaultTableModel tabel = new DefaultTableModel();
    public Model_booking(){
       
        getTabel().addColumn("Kode");
        getTabel().addColumn("Tanggal");
        getTabel().addColumn("Waktu");
        getTabel().addColumn("Nama");
        getTabel().addColumn("Team");
        getTabel().addColumn("No HP");
      
    }
   
 


    /**
     * @return the tabel
     */
    public DefaultTableModel getTabel() {
        return tabel;
    }

    /**
     * @param tabel the tabel to set
     */
    public void setTabel(DefaultTableModel tabel) {
        this.tabel = tabel;
    }

   
    
}

6. kemudian buat jframe dengan bentuk design seperti gambar dibawah ini :
 

















 



dan isi source dengan koding dibawah ini :

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package booking_lapangan_futsal;

import java.awt.event.KeyEvent;
import java.text.NumberFormat;

/**
 *
 * @author Ardy Sendleep
 */
public class Frame_booking_lapangan extends javax.swing.JFrame {
    double nama,harga,jmlhjual,total;
    Model_booking penjualan = new Model_booking();

    /**
     * Creates new form Frame_booking_lapangan
     */
    public Frame_booking_lapangan() {
        initComponents();
        tblBarang.setModel(penjualan.getTabel());
       
        kode.addItem("LPNG01");
        kode.addItem("LPNG02");
        kode.addItem("LPNG03");
        kode.addItem("LPNG04");
        kode.addItem("LPNG05");
       
       
       
        for (int a=1; a<=31; a++){
            Tgl.addItem(a);
        }
       
        Bln.addItem("Januari");
        Bln.addItem("Februari");
        Bln.addItem("Maret");
        Bln.addItem("April");
        Bln.addItem("Mei");
        Bln.addItem("Juni");
        Bln.addItem("Juli");
        Bln.addItem("Agustus");
        Bln.addItem("September");
        Bln.addItem("Oktober"); 
        Bln.addItem("November");
        Bln.addItem("Desember");
       
        for (int b=2000; b<=2016; b++){
        Thn.addItem(b);       
        }
       
        Jam1.addItem("08.00");
        Jam1.addItem("09.00");
        Jam1.addItem("10.00");
        Jam1.addItem("11.00");
        Jam1.addItem("12.00");
        Jam1.addItem("13.00");
        Jam1.addItem("14.00");
        Jam1.addItem("15.00");
        Jam1.addItem("16.00");
        Jam1.addItem("17.00");
        Jam1.addItem("18.00");
        Jam1.addItem("19.00");
        Jam1.addItem("20.00");
        Jam1.addItem("21.00");
        Jam1.addItem("22.00");
        Jam1.addItem("23.00");
        Jam1.addItem("24.00");
       
        Jam2.addItem("08.00");
        Jam2.addItem("09.00");
        Jam2.addItem("10.00");
        Jam2.addItem("11.00");
        Jam2.addItem("12.00");
        Jam2.addItem("13.00");
        Jam2.addItem("14.00");
        Jam2.addItem("15.00");
        Jam2.addItem("16.00");
        Jam2.addItem("17.00");
        Jam2.addItem("18.00");
        Jam2.addItem("19.00");
        Jam2.addItem("20.00");
        Jam2.addItem("21.00");
        Jam2.addItem("22.00");
        Jam2.addItem("23.00");
        Jam2.addItem("24.00");
      
    }

    /**
     * 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() {

        jLabel2 = new javax.swing.JLabel();
        jLabel1 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jScrollPane2 = new javax.swing.JScrollPane();
        tblBarang = new javax.swing.JTable();
        btnPesan = new javax.swing.JButton();
        jLabel5 = new javax.swing.JLabel();
        txtNama = new javax.swing.JTextField();
        btnHapus = new javax.swing.JButton();
        jLabel6 = new javax.swing.JLabel();
        txtTeam = new javax.swing.JTextField();
        jLabel7 = new javax.swing.JLabel();
        txtNo = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        Tgl = new javax.swing.JComboBox();
        Bln = new javax.swing.JComboBox();
        Thn = new javax.swing.JComboBox();
        Jam1 = new javax.swing.JComboBox();
        Jam2 = new javax.swing.JComboBox();
        jLabel8 = new javax.swing.JLabel();
        kode = new javax.swing.JComboBox();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jLabel2.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jLabel2.setText("Kode Booking");

        jLabel1.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
        jLabel1.setText("Program Booking Lapangan Futsal");

        jLabel3.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jLabel3.setText("Tanggal Pemesanan");

        tblBarang.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        jScrollPane2.setViewportView(tblBarang);

        btnPesan.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        btnPesan.setText("Pesan");
        btnPesan.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnPesanActionPerformed(evt);
            }
        });

        jLabel5.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jLabel5.setText("Nama Pemesan");

        txtNama.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        txtNama.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                txtNamaKeyPressed(evt);
            }
        });

        btnHapus.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        btnHapus.setText("Hapus");
        btnHapus.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnHapusActionPerformed(evt);
            }
        });

        jLabel6.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jLabel6.setText("No Handphone");

        txtTeam.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        txtTeam.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                txtTeamKeyPressed(evt);
            }
        });

        jLabel7.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jLabel7.setText("Nama Team");

        txtNo.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        txtNo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtNoActionPerformed(evt);
            }
        });
        txtNo.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                txtNoKeyPressed(evt);
            }
        });

        jLabel4.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jLabel4.setText("Waktu");

        Tgl.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Tanggal" }));
        Tgl.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                TglActionPerformed(evt);
            }
        });

        Bln.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Bulan" }));

        Thn.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Tahun" }));

        Jam1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Mulai" }));

        Jam2.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Selesai" }));

        jLabel8.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jLabel8.setText("Sampai");

        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(26, 26, 26)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                        .addGroup(layout.createSequentialGroup()
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jLabel3)
                                .addComponent(jLabel2))
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                    .addComponent(Tgl, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(Bln, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(Thn, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addComponent(kode, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 242, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addGroup(layout.createSequentialGroup()
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(layout.createSequentialGroup()
                                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addComponent(jLabel6)
                                        .addComponent(jLabel5)
                                        .addComponent(jLabel7))
                                    .addGap(0, 0, Short.MAX_VALUE))
                                .addComponent(jLabel4))
                            .addGap(213, 213, 213)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                .addGroup(layout.createSequentialGroup()
                                    .addComponent(btnPesan)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 92, Short.MAX_VALUE)
                                    .addComponent(btnHapus))
                                .addGroup(layout.createSequentialGroup()
                                    .addComponent(Jam1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                    .addComponent(jLabel8)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(Jam2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addComponent(txtNama)
                                .addComponent(txtNo)
                                .addComponent(txtTeam))))
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 561, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18))
            .addGroup(layout.createSequentialGroup()
                .addGap(140, 140, 140)
                .addComponent(jLabel1)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(30, 30, 30)
                .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(45, 45, 45)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(kode, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(Tgl, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(Bln, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(Thn, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(Jam1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(Jam2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel8))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtNama, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtTeam, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel7))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel6)
                    .addComponent(txtNo, javax.swing.GroupLayout.Alignment.TRAILING, 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(btnHapus)
                    .addComponent(btnPesan))
                .addGap(18, 18, 18)
                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 153, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(54, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>                       

    private void btnPesanActionPerformed(java.awt.event.ActionEvent evt) {                                        
        String[] data = new String[6];
        data[0] = (""+kode.getSelectedItem());
        data[1]= (""+Tgl.getSelectedItem()+"-"+Bln.getSelectedItem()+"-"+Thn.getSelectedItem());
        data[2] = (""+Jam1.getSelectedItem()+"-"+Jam2.getSelectedItem());
        data[3] = txtNama.getText();
        data[4] = txtTeam.getText();
        data[5] = txtNo.getText();
       
  
        penjualan.getTabel().addRow(data);
      
    }                                       

    private void txtNamaKeyPressed(java.awt.event.KeyEvent evt) {                                  
        // TODO add your handling code here:
    }                                 

    private void btnHapusActionPerformed(java.awt.event.ActionEvent evt) {                                        
        penjualan.getTabel().removeRow(tblBarang.getSelectedRow());
    }                                       

    private void txtTeamKeyPressed(java.awt.event.KeyEvent evt) {                                  
        // TODO add your handling code here:
    }                                 

    private void txtNoKeyPressed(java.awt.event.KeyEvent evt) {                                
        // TODO add your handling code here:
    }                               

    private void TglActionPerformed(java.awt.event.ActionEvent evt) {                                   
        // TODO add your handling code here:
    }                                  

    private void txtNoActionPerformed(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_booking_lapangan.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(Frame_booking_lapangan.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(Frame_booking_lapangan.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(Frame_booking_lapangan.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_booking_lapangan().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify                    
    private javax.swing.JComboBox Bln;
    private javax.swing.JComboBox Jam1;
    private javax.swing.JComboBox Jam2;
    private javax.swing.JComboBox Tgl;
    private javax.swing.JComboBox Thn;
    private javax.swing.JButton btnHapus;
    private javax.swing.JButton btnPesan;
    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 jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JComboBox kode;
    private javax.swing.JTable tblBarang;
    private javax.swing.JTextField txtNama;
    private javax.swing.JTextField txtNo;
    private javax.swing.JTextField txtTeam;
    // End of variables declaration                  
}


Setelah semua selesai dan lebih kurang yang dibuat seperti gambar dibawah ini :

Oke jika semua sudah selesai silahkan dirunningkan.

Yang ingin aplikasi jadinya bisa di download dibawah ini :
Aplikasi Penyewaan Lapangan Futsal : Download Aplikasi
Yang ingin makalahnya juga ada : Download Makalah

Jika ada masalah tanyakan saja di komentar


Sekian Terima Kasih........ 
Sunday, July 29, 2018 July 29, 2018 - tanpa komentar

No comments:

Post a Comment