Senin, 12 Juni 2017

Program Laundry Pakaian

Program Laundry Pakaian Java Sederhana

           Ya Teman - Teman Kali ini saya akan memberikan contoh tentang Aplikasi Laundry pakian 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.



classLaundry


package laundry;

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



ClasscalssLaundry

package laundry;

public class ClassLaundry {
    public String namaPelanggan;
    public String jenisCucian;
    public String kategori;
    public float harga;
   
    @Override
    public String toString(){
        return namaPelanggan +" - " + jenisCucian +" - " + kategori + " - " + harga ;
    }
   
   
}
   
    public ModelPaket(String namaPaket, String isiPaket, float harga){
        this.namaPaket=namaPaket;
        this.isiPaket=isiPaket;
        this.harga=harga;
    }
    /**
     * @return the namaPaket
     */
    public String getNamaPaket() {
        return namaPaket;
    }

    /**
     * @param namaPaket the namaPaket to set
     */
    public void setNamaPaket(String namaPaket) {
        this.namaPaket = namaPaket;
    }

    /**
     * @return the isiPaket
     */
    public String getIsiPaket() {
        return isiPaket;
    }

    /**
     * @param isiPaket the isiPaket to set
     */
    public void setIsiPaket(String isiPaket) {
        this.isiPaket = isiPaket;
    }

    /**
     * @return the harga
     */
    public float getHarga() {
        return harga;
    }

    /**
     * @param harga the harga to set
     */
    public void setHarga(float harga) {
        this.harga = harga;
    }

    @Override
    public String toString() {
        return namaPaket;
    }
   
   
   
}


ClassLaundryView


package laundry;
import javax.swing.DefaultListModel;

public class LaundryView extends javax.swing.JFrame {
    DefaultListModel<ClassLaundry> Baju = new DefaultListModel<>();
    private String namaPelanggan;
    private String jenisCucian;
    private String kategori;
    private float harga;
    private ClassLaundry ClassLaundry;
   
    /**
     * Creates new form LaundryView
     */
    public LaundryView() {
        initComponents();
        ListMenu.setModel(Baju);
        cboKategori.addItem("Regular");
        cboKategori.addItem("Dry Cleaning");
        cboKategori.addItem("Wet Cleaning");
           
       
    }
   
    @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();
        txtJenis = new javax.swing.JTextField();
        txtHarga = new javax.swing.JTextField();
        cboKategori = new javax.swing.JComboBox();
        jScrollPane1 = new javax.swing.JScrollPane();
        ListMenu = new javax.swing.JList();
        btnSimpan = new javax.swing.JButton();
        jLabel4 = new javax.swing.JLabel();
        Breset = new javax.swing.JButton();
        Bkeluar = new javax.swing.JButton();
        jLabel5 = new javax.swing.JLabel();
        txtNama = new javax.swing.JTextField();
        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        jLabel1.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jLabel1.setText("Jenis Cucian");
        jLabel2.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jLabel2.setText("Kategori");
        jLabel3.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jLabel3.setText("Harga");
        txtJenis.setName(""); // NOI18N
        txtJenis.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtJenisActionPerformed(evt);
            }
        });
        txtHarga.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtHargaActionPerformed(evt);
            }
        });
        cboKategori.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cboKategoriActionPerformed(evt);
            }
        });
        ListMenu.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                ListMenuMouseClicked(evt);
            }
        });
        jScrollPane1.setViewportView(ListMenu);
        btnSimpan.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        btnSimpan.setText("Simpan");
        btnSimpan.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSimpanActionPerformed(evt);
            }
        });
        jLabel4.setFont(new java.awt.Font("Tahoma", 1, 24)); // NOI18N
        jLabel4.setText("Program Laundry Pakaian");
        Breset.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        Breset.setText("Reset");
        Breset.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BresetActionPerformed(evt);
            }
        });
        Bkeluar.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        Bkeluar.setText("Keluar");
        Bkeluar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BkeluarActionPerformed(evt);
            }
        });
        jLabel5.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jLabel5.setText("Nama Pelanggan");
        txtNama.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtNamaActionPerformed(evt);
            }
        });
        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addGap(21, 21, 21)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel1)
                    .addComponent(jLabel3)
                    .addComponent(jLabel2)
                    .addComponent(jLabel5))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 28, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 315, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(btnSimpan, javax.swing.GroupLayout.PREFERRED_SIZE, 86, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(Breset, javax.swing.GroupLayout.PREFERRED_SIZE, 74, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(txtJenis)
                            .addComponent(cboKategori, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(txtNama)
                            .addComponent(txtHarga, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 190, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addGap(18, 18, 18)
                                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 231, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                .addGap(172, 172, 172)
                                .addComponent(Bkeluar)))))
                .addGap(22, 22, 22))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(25, 25, 25)
                .addComponent(jLabel4)
                .addGap(42, 42, 42)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel5)
                            .addComponent(txtNama, 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(txtJenis, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel1))
                        .addGap(14, 14, 14)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(cboKategori, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel2))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(txtHarga, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel3)))
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnSimpan)
                    .addComponent(Breset)
                    .addComponent(Bkeluar))
                .addContainerGap(21, Short.MAX_VALUE))
        );
        pack();
    }// </editor-fold>                       
    private void btnSimpanActionPerformed(java.awt.event.ActionEvent evt) {                                         
        // TODO add your handling code here:
        ClassLaundry LN = new ClassLaundry();
        LN.namaPelanggan=txtNama.getText();
        LN.jenisCucian=txtJenis.getText();
        LN.kategori= (String)cboKategori.getSelectedItem();
        LN.harga= Float.parseFloat(txtHarga.getText());
        txtNama.setText("");
        txtJenis.setText("");
        txtHarga.setText("");
        Baju.addElement(LN);
    }                                        
    private void cboKategoriActionPerformed(java.awt.event.ActionEvent evt) {                                           
        // TODO add your handling code here:
 
    }                                          
    private void ListMenuMouseClicked(java.awt.event.MouseEvent evt) {                                     
        // TODO add your handling code here:
        int index=ListMenu.getSelectedIndex();
        ClassLaundry LN = Baju.getElementAt(index);
        txtNama.setText(LN.namaPelanggan);
        txtJenis.setText(LN.jenisCucian);
        txtHarga.setText(Float.toString(LN.harga));
      
    }                                    
    private void BresetActionPerformed(java.awt.event.ActionEvent evt) {                                      
        // TODO add your handling code here:
        int index = ListMenu.getSelectedIndex();
        Baju.removeElementAt(index);
        txtNama.setText("");
        txtJenis.setText("");
        txtHarga.setText("");
    }                                     
    private void BkeluarActionPerformed(java.awt.event.ActionEvent evt) {                                       
        // TODO add your handling code here:
        this.setVisible(false);
        System.exit(0);
    }                                      
    private void txtJenisActionPerformed(java.awt.event.ActionEvent evt) {                                        
        // TODO add your handling code here:
    }                                       
    private void txtHargaActionPerformed(java.awt.event.ActionEvent evt) {                                        
        // TODO add your handling code here:
    }                                       
    private void txtNamaActionPerformed(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(LaundryView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(LaundryView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(LaundryView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(LaundryView.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 LaundryView().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify                    
    private javax.swing.JButton Bkeluar;
    private javax.swing.JButton Breset;
    private javax.swing.JList ListMenu;
    private javax.swing.JButton btnSimpan;
    private javax.swing.JComboBox cboKategori;
    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.JScrollPane jScrollPane1;
    private javax.swing.JTextField txtHarga;
    private javax.swing.JTextField txtJenis;
    private javax.swing.JTextField txtNama;
    // End of variables declaration                  
}




Dan Berikut Ini Design Tampilanya Gan :



Jalankan Program :
Langkah terakhir adalah menjalankan program dengan memilih Run Main Project(F6) atau Pilih Project > Klik kanan > Run. Selanjutnya akan muncul program yang telah Anda buat. Anda dapat memilih Kategori Laundry yang anda inginkan ya boss...hehehehe 
:) dan jangan lupa di cuci bajunya ya guys biar bersih hehehehe :)



Terimakasih telah mengunjungi blog saya ini.
Pengunjung yg baik selalu ninggalin jejak :)

Salam Wani Sinau!

Note : Shilakan mencoba bila masih kesulitan mebuat project
ini bisa komentar di bawah ini siap saya bantu.


Tidak ada komentar:

Posting Komentar