Minggu, 13 Januari 2019

membuat aplikasi kasir toko elektronik sederhana dengan NETBEANS

1. Deskripsi Aplikasi

Aplikasi toko elektronik ini dibuat untuk memudahkan para penjual dan pembeli dalam bertransaksi. aplikasi ini terdiri dari 3 item saja, cara kerja aplikasi ini sangat sederhana ,cukup dengan mengklik item dan menuliskan jumlahnya setelah itu klik hitung ,harga total dari item akan langsung tertera di aplikasi.

list item dan harga

kulkas = 3.000.000
televisi = 2.300.000
mesin cuci = 4.800.000


2. Screenshot Desain




3. Screenshot run aplikasi




4. source code


/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package javaapplication1;
/**
 *
 * @author Shofan
 */
public class elektroshop extends javax.swing.JFrame {
    /**
     * Creates new form elektroshop
     */
    public elektroshop() {
        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() {
        jPanel1 = new javax.swing.JPanel();
        jPanel2 = new javax.swing.JPanel();
        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        jButton3 = new javax.swing.JButton();
        cbkulkas = new javax.swing.JCheckBox();
        cbtelevisi = new javax.swing.JCheckBox();
        cbmesin = new javax.swing.JCheckBox();
        txtkulkas = new javax.swing.JTextField();
        txttelevisi = new javax.swing.JTextField();
        txtmesin = new javax.swing.JTextField();
        txttotal = new javax.swing.JTextField();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 100, Short.MAX_VALUE)
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 100, Short.MAX_VALUE)
        );
        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        jButton1.setText("KELUAR");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });
        jButton2.setText("HITUNG");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });
        jButton3.setText("RESET");
        jButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton3ActionPerformed(evt);
            }
        });
        cbkulkas.setText("KULKAS");
        cbkulkas.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cbkulkasActionPerformed(evt);
            }
        });
        cbtelevisi.setText("TELEVISI");
        cbtelevisi.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cbtelevisiActionPerformed(evt);
            }
        });
        cbmesin.setText("MESIN CUCI");
        cbmesin.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cbmesinActionPerformed(evt);
            }
        });
        txtkulkas.setEditable(false);
        txtkulkas.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtkulkasActionPerformed(evt);
            }
        });
        txttelevisi.setEditable(false);
        txttelevisi.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txttelevisiActionPerformed(evt);
            }
        });
        txtmesin.setEditable(false);
        txtmesin.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtmesinActionPerformed(evt);
            }
        });
        txttotal.setEditable(false);
        jLabel1.setText("TOTAL");
        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jButton1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 149, Short.MAX_VALUE)
                        .addComponent(jButton3)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButton2))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel2Layout.createSequentialGroup()
                                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(cbkulkas, javax.swing.GroupLayout.PREFERRED_SIZE, 96, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(cbtelevisi, javax.swing.GroupLayout.PREFERRED_SIZE, 96, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(cbmesin, javax.swing.GroupLayout.PREFERRED_SIZE, 96, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGap(85, 85, 85))
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                                .addComponent(jLabel1)
                                .addGap(27, 27, 27)))
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(txttotal, javax.swing.GroupLayout.DEFAULT_SIZE, 170, Short.MAX_VALUE)
                            .addComponent(txtkulkas)
                            .addComponent(txttelevisi)
                            .addComponent(txtmesin))
                        .addGap(0, 0, Short.MAX_VALUE)))
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                .addGap(43, 43, 43)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(cbkulkas)
                    .addComponent(txtkulkas, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(cbtelevisi)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(txttelevisi, javax.swing.GroupLayout.PREFERRED_SIZE, 15, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(2, 2, 2)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(cbmesin)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(txtmesin, javax.swing.GroupLayout.PREFERRED_SIZE, 18, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(2, 2, 2)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 45, Short.MAX_VALUE)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txttotal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel1))
                .addGap(36, 36, 36)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton1)
                    .addComponent(jButton2)
                    .addComponent(jButton3))
                .addContainerGap())
        );
        jLabel2.setBackground(new java.awt.Color(255, 255, 255));
        jLabel2.setFont(new java.awt.Font("Algerian", 0, 14)); // NOI18N
        jLabel2.setForeground(new java.awt.Color(255, 51, 204));
        jLabel2.setText("elektro shop");
        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
            .addGroup(layout.createSequentialGroup()
                .addGap(125, 125, 125)
                .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 111, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
        pack();
    }// </editor-fold>                       
    private void txtmesinActionPerformed(java.awt.event.ActionEvent evt) {                                       
        // TODO add your handling code here:
    }                                       
    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                       
      System.exit(0);
    }                                       
    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {                                       
      txtkulkas.setText("");
       txttelevisi.setText("");
        txtmesin.setText("");
         txttotal.setText("");
    }                                       
    private void cbkulkasActionPerformed(java.awt.event.ActionEvent evt) {                                       
        if(cbkulkas.isSelected()==true){
            txtkulkas.setEditable(true);
        }else{
            txtkulkas.setEditable(false);
        }
         if(cbtelevisi.isSelected()==true){
            txttelevisi.setEditable(true);
        }else{
            txttelevisi.setEditable(false);
        }
          if(cbmesin.isSelected()==true){
            txtmesin.setEditable(true);
        }else{
            txtmesin.setEditable(false);
        }
       
    }                                       
    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {                                       
    int total = 0;
    if(cbkulkas.isSelected()==true){
        int jumlahkulkas = Integer.parseInt(txtkulkas.getText());
        int hargakulkas = jumlahkulkas*3000000;
        total = total+hargakulkas;
    }
   
    if(cbtelevisi.isSelected()==true){
        int jumlahtelevisi = Integer.parseInt(txttelevisi.getText());
        int hargatelevisi = jumlahtelevisi*2300000;
        total = total+hargatelevisi;
    }
 
    if(cbmesin.isSelected()==true){
        int jumlahmesin = Integer.parseInt(txtmesin.getText());
        int hargamesin = jumlahmesin*4800000;
        total = total+hargamesin;
    }
    txttotal.setText(String.valueOf(total));
    }                                       
    private void txttelevisiActionPerformed(java.awt.event.ActionEvent evt) {                                           
        // TODO add your handling code here:
    }                                         
    private void txtkulkasActionPerformed(java.awt.event.ActionEvent evt) {                                         
        // TODO add your handling code here:
    }                                       
    private void cbtelevisiActionPerformed(java.awt.event.ActionEvent evt) {                                         
       if(cbkulkas.isSelected()==true){
            txtkulkas.setEditable(true);
        }else{
            txtkulkas.setEditable(false);
        }
         if(cbtelevisi.isSelected()==true){
            txttelevisi.setEditable(true);
        }else{
            txttelevisi.setEditable(false);
        }
          if(cbmesin.isSelected()==true){
            txtmesin.setEditable(true);
        }else{
            txtmesin.setEditable(false);
        }
    }                                         
    private void cbmesinActionPerformed(java.awt.event.ActionEvent evt) {                                       
         if(cbkulkas.isSelected()==true){
            txtkulkas.setEditable(true);
        }else{
            txtkulkas.setEditable(false);
        }
         if(cbtelevisi.isSelected()==true){
            txttelevisi.setEditable(true);
        }else{
            txttelevisi.setEditable(false);
        }
          if(cbmesin.isSelected()==true){
            txtmesin.setEditable(true);
        }else{
            txtmesin.setEditable(false);
        }
    }                                     
    /**
     * @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(elektroshop.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(elektroshop.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(elektroshop.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(elektroshop.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 elektroshop().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify                   
    private javax.swing.JCheckBox cbkulkas;
    private javax.swing.JCheckBox cbmesin;
    private javax.swing.JCheckBox cbtelevisi;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JTextField txtkulkas;
    private javax.swing.JTextField txtmesin;
    private javax.swing.JTextField txttelevisi;
    private javax.swing.JTextField txttotal;
    // End of variables declaration                 
}




sekian dan terimakasih.