facturas.Facture.java Source code

Java tutorial

Introduction

Here is the source code for facturas.Facture.java

Source

/*
 * 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 facturas;

import java.awt.Color;
import java.text.NumberFormat;
import javax.swing.ImageIcon;
import javax.swing.JOptionPane;
import javazoom.jl.player.Player;
import org.apache.commons.validator.routines.EmailValidator;

/**
 *
 * @author Antonio
 */
public class Facture extends javax.swing.JFrame {

    /**
     * Creates new form Facture
     */
    public Facture() {
        initComponents();
        setIconImage(new ImageIcon(getClass().getResource("/Images/icono.png")).getImage());
        this.setTitle("Facture Application");
        this.setLocationRelativeTo(null);
        getRootPane().setDefaultButton(jButtonPrecioTotal);
        //Hacemos que los campos jText Field siguientes no puedan ser editables
        jTextFieldIva.setEditable(false);
        jTextFieldIva.setForeground(Color.BLUE);
        jTextFieldIva1.setEditable(false);
        jTextFieldIva1.setForeground(Color.BLUE);
        jTextFieldIva2.setEditable(false);
        jTextFieldIva2.setForeground(Color.BLUE);
        jTextFieldIva3.setEditable(false);
        jTextFieldIva3.setForeground(Color.BLUE);
        jTextFieldTotal.setEditable(false);
        jTextFieldTotal.setForeground(Color.BLUE);
        jTextFieldTotal1.setEditable(false);
        jTextFieldTotal1.setForeground(Color.BLUE);
        jTextFieldTotal2.setEditable(false);
        jTextFieldTotal2.setForeground(Color.BLUE);
        jTextFieldTotal3.setEditable(false);
        jTextFieldTotal3.setForeground(Color.BLUE);
        jTextFieldTotalPrice.setEditable(false);
        jTextFieldTotalPrice.setForeground(Color.RED);
        jTextFieldTotalPrice.setBackground(Color.LIGHT_GRAY);
    }

    /**
     * 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">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel4 = new javax.swing.JLabel();
        jButtonPay = new javax.swing.JButton();
        jButtonPayWithCard = new javax.swing.JButton();
        jPanel2 = new javax.swing.JPanel();
        jTextFieldPrice = new javax.swing.JTextField();
        jTextFieldPrice1 = new javax.swing.JTextField();
        jTextFieldPrice3 = new javax.swing.JTextField();
        jTextFieldPrice2 = new javax.swing.JTextField();
        jTextFieldUnits = new javax.swing.JTextField();
        jTextFieldUnits1 = new javax.swing.JTextField();
        jTextFieldUnits3 = new javax.swing.JTextField();
        jTextFieldUnits2 = new javax.swing.JTextField();
        jTextFieldIva = new javax.swing.JTextField();
        jTextFieldIva1 = new javax.swing.JTextField();
        jTextFieldIva3 = new javax.swing.JTextField();
        jTextFieldIva2 = new javax.swing.JTextField();
        jTextFieldTotal = new javax.swing.JTextField();
        jTextFieldTotal1 = new javax.swing.JTextField();
        jTextFieldTotal3 = new javax.swing.JTextField();
        jTextFieldTotal2 = new javax.swing.JTextField();
        jTextFieldIva4 = new javax.swing.JTextField();
        jTextFieldIva5 = new javax.swing.JTextField();
        jTextFieldIva6 = new javax.swing.JTextField();
        jTextFieldIva7 = new javax.swing.JTextField();
        jPanel1 = new javax.swing.JPanel();
        jLabel5 = new javax.swing.JLabel();
        jDateChooser1 = new com.toedter.calendar.JDateChooser();
        jLabelClient = new javax.swing.JLabel();
        jTextField1 = new javax.swing.JTextField();
        jPanel3 = new javax.swing.JPanel();
        jLabel9 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jTextFieldEmail = new javax.swing.JTextField();
        jLabel10 = new javax.swing.JLabel();
        jTextField2 = new javax.swing.JTextField();
        jPanel4 = new javax.swing.JPanel();
        jLabel7 = new javax.swing.JLabel();
        jPanel5 = new javax.swing.JPanel();
        jLabel3 = new javax.swing.JLabel();
        jPanel6 = new javax.swing.JPanel();
        jLabel2 = new javax.swing.JLabel();
        jPanel7 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jPanel8 = new javax.swing.JPanel();
        jPanel9 = new javax.swing.JPanel();
        jButtonPrecioTotal = new javax.swing.JButton();
        jTextFieldTotalPrice = new javax.swing.JTextField();
        jPanel10 = new javax.swing.JPanel();
        jButtonVersion = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setIconImage(getIconImage());
        setResizable(false);
        getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jLabel4.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel4.setText("CONCEPTO");
        getContentPane().add(jLabel4, new org.netbeans.lib.awtextra.AbsoluteConstraints(21, 91, 80, 30));

        jButtonPay.setLabel("Pagar  contra-reembolso");
        jButtonPay.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonPayActionPerformed(evt);
            }
        });
        getContentPane().add(jButtonPay, new org.netbeans.lib.awtextra.AbsoluteConstraints(110, 290, -1, -1));

        jButtonPayWithCard.setText("Pagar con tarjeta");
        jButtonPayWithCard.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonPayWithCardActionPerformed(evt);
            }
        });
        getContentPane().add(jButtonPayWithCard,
                new org.netbeans.lib.awtextra.AbsoluteConstraints(270, 290, 147, -1));

        jPanel2.setBackground(new java.awt.Color(204, 204, 204));
        jPanel2.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jPanel2.setToolTipText("");

        jTextFieldPrice.setText("0");

        jTextFieldPrice1.setText("0");

        jTextFieldPrice3.setText("0");

        jTextFieldPrice2.setText("0");

        jTextFieldUnits.setText("0");
        jTextFieldUnits.setCursor(new java.awt.Cursor(java.awt.Cursor.TEXT_CURSOR));

        jTextFieldUnits1.setText("0");

        jTextFieldUnits3.setText("0");

        jTextFieldUnits2.setText("0");

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(jPanel2Layout
                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                        .addContainerGap().addGroup(
                                jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addComponent(jTextFieldIva4, javax.swing.GroupLayout.DEFAULT_SIZE, 275,
                                                Short.MAX_VALUE)
                                        .addComponent(jTextFieldIva5)
                                        .addComponent(jTextFieldIva6, javax.swing.GroupLayout.Alignment.TRAILING)
                                        .addComponent(jTextFieldIva7, javax.swing.GroupLayout.Alignment.TRAILING))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jTextFieldPrice1, javax.swing.GroupLayout.PREFERRED_SIZE, 55,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jTextFieldPrice, javax.swing.GroupLayout.PREFERRED_SIZE, 55,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jTextFieldPrice2, javax.swing.GroupLayout.PREFERRED_SIZE, 55,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jTextFieldPrice3, javax.swing.GroupLayout.PREFERRED_SIZE, 55,
                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(42, 42, 42)
                        .addGroup(jPanel2Layout
                                .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                .addGroup(jPanel2Layout.createSequentialGroup()
                                        .addComponent(jTextFieldUnits, javax.swing.GroupLayout.PREFERRED_SIZE, 34,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addGap(41, 41, 41).addComponent(jTextFieldIva,
                                                javax.swing.GroupLayout.PREFERRED_SIZE, 61,
                                                javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGroup(jPanel2Layout.createSequentialGroup()
                                        .addComponent(jTextFieldUnits3, javax.swing.GroupLayout.PREFERRED_SIZE, 34,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addGap(41, 41, 41).addComponent(jTextFieldIva3,
                                                javax.swing.GroupLayout.PREFERRED_SIZE, 61,
                                                javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGroup(jPanel2Layout.createSequentialGroup()
                                        .addComponent(jTextFieldUnits2, javax.swing.GroupLayout.PREFERRED_SIZE, 34,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
                                                javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                        .addComponent(jTextFieldIva2, javax.swing.GroupLayout.PREFERRED_SIZE, 61,
                                                javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGroup(jPanel2Layout.createSequentialGroup()
                                        .addComponent(jTextFieldUnits1, javax.swing.GroupLayout.PREFERRED_SIZE, 34,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addGap(41, 41, 41).addComponent(jTextFieldIva1,
                                                javax.swing.GroupLayout.PREFERRED_SIZE, 61,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addGap(52, 52, 52)
                        .addGroup(
                                jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                        .addComponent(jTextFieldTotal2, javax.swing.GroupLayout.DEFAULT_SIZE, 118,
                                                Short.MAX_VALUE)
                                        .addComponent(jTextFieldTotal1, javax.swing.GroupLayout.Alignment.TRAILING)
                                        .addComponent(jTextFieldTotal, javax.swing.GroupLayout.Alignment.TRAILING)
                                        .addComponent(jTextFieldTotal3))
                        .addContainerGap()));
        jPanel2Layout.setVerticalGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel2Layout.createSequentialGroup().addGap(6, 6, 6).addGroup(jPanel2Layout
                        .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jTextFieldPrice, javax.swing.GroupLayout.PREFERRED_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jTextFieldUnits, javax.swing.GroupLayout.PREFERRED_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jTextFieldIva, javax.swing.GroupLayout.PREFERRED_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jTextFieldTotal, javax.swing.GroupLayout.PREFERRED_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jTextFieldIva5, 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.BASELINE)
                                .addComponent(jTextFieldPrice1, javax.swing.GroupLayout.PREFERRED_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jTextFieldUnits1, javax.swing.GroupLayout.PREFERRED_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jTextFieldIva1, javax.swing.GroupLayout.PREFERRED_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jTextFieldTotal1, javax.swing.GroupLayout.PREFERRED_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jTextFieldIva6, 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.BASELINE)
                                .addComponent(jTextFieldPrice3, javax.swing.GroupLayout.PREFERRED_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jTextFieldUnits3, javax.swing.GroupLayout.PREFERRED_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jTextFieldIva3, javax.swing.GroupLayout.PREFERRED_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jTextFieldTotal3, javax.swing.GroupLayout.PREFERRED_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jTextFieldIva7, 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.BASELINE)
                                .addComponent(jTextFieldPrice2, javax.swing.GroupLayout.PREFERRED_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jTextFieldUnits2, javax.swing.GroupLayout.PREFERRED_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jTextFieldIva2, javax.swing.GroupLayout.PREFERRED_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jTextFieldTotal2, javax.swing.GroupLayout.PREFERRED_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jTextFieldIva4, javax.swing.GroupLayout.PREFERRED_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addContainerGap(42, Short.MAX_VALUE)));

        getContentPane().add(jPanel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 120, 720, 150));

        jPanel1.setBackground(new java.awt.Color(204, 204, 204));
        jPanel1.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        jLabel5.setBackground(new java.awt.Color(204, 204, 204));
        jLabel5.setFont(new java.awt.Font("Forte", 1, 18)); // NOI18N
        jLabel5.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel5.setText("FACTURAS");

        jDateChooser1.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        jLabelClient.setFont(new java.awt.Font("Rage Italic", 0, 18)); // NOI18N
        jLabelClient.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabelClient.setText("Cliente");

        jTextField1.setFont(new java.awt.Font("Verdana", 0, 11)); // NOI18N

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(jPanel1Layout
                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel1Layout.createSequentialGroup().addContainerGap().addGroup(jPanel1Layout
                        .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                        .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(jLabel5, javax.swing.GroupLayout.DEFAULT_SIZE, 219, Short.MAX_VALUE)
                                .addGap(18, 18, 18).addComponent(jDateChooser1,
                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(jLabelClient, javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 216,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addContainerGap()));
        jPanel1Layout.setVerticalGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel1Layout.createSequentialGroup().addGroup(jPanel1Layout
                        .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(jPanel1Layout.createSequentialGroup().addContainerGap().addComponent(
                                jDateChooser1, javax.swing.GroupLayout.PREFERRED_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 36,
                                javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jLabelClient))
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));

        getContentPane().add(jPanel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 11, 360, 80));

        jPanel3.setBackground(new java.awt.Color(204, 204, 204));
        jPanel3.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        jLabel8.setFont(new java.awt.Font("Rage Italic", 0, 18)); // NOI18N
        jLabel8.setText("Correo Electrnico");

        jTextFieldEmail.setFont(new java.awt.Font("Verdana", 0, 11)); // NOI18N

        jLabel10.setFont(new java.awt.Font("Rage Italic", 0, 18)); // NOI18N
        jLabel10.setText("Tfno. de Contacto");

        jTextField2.setFont(new java.awt.Font("Verdana", 0, 11)); // NOI18N

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(jPanel3Layout
                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel3Layout.createSequentialGroup().addGroup(jPanel3Layout
                        .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                        .addGroup(javax.swing.GroupLayout.Alignment.LEADING,
                                jPanel3Layout.createSequentialGroup().addGap(12, 12, 12).addComponent(jLabel8)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(jTextFieldEmail, javax.swing.GroupLayout.DEFAULT_SIZE, 201,
                                                Short.MAX_VALUE))
                        .addGroup(javax.swing.GroupLayout.Alignment.LEADING,
                                jPanel3Layout.createSequentialGroup().addGap(58, 58, 58).addComponent(jLabel9)
                                        .addGap(0, 0, Short.MAX_VALUE))
                        .addGroup(jPanel3Layout.createSequentialGroup().addContainerGap()
                                .addComponent(jLabel10, javax.swing.GroupLayout.PREFERRED_SIZE, 122,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jTextField2)))
                        .addContainerGap()));
        jPanel3Layout.setVerticalGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel3Layout.createSequentialGroup().addGap(15, 15, 15)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(jLabel10).addComponent(jTextField2,
                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
                                javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, 24,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jTextFieldEmail, javax.swing.GroupLayout.PREFERRED_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18).addComponent(jLabel9).addContainerGap()));

        getContentPane().add(jPanel3, new org.netbeans.lib.awtextra.AbsoluteConstraints(373, 10, 350, 80));

        jPanel4.setBackground(new java.awt.Color(204, 204, 204));
        jPanel4.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        jLabel7.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel7.setText("TOTAL ");
        jLabel7.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout
                .setHorizontalGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
                                jPanel4Layout.createSequentialGroup()
                                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                        .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, 116,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addContainerGap()));
        jPanel4Layout.setVerticalGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
                        jPanel4Layout.createSequentialGroup().addGap(0, 0, Short.MAX_VALUE).addComponent(jLabel7,
                                javax.swing.GroupLayout.PREFERRED_SIZE, 26,
                                javax.swing.GroupLayout.PREFERRED_SIZE)));

        getContentPane().add(jPanel4, new org.netbeans.lib.awtextra.AbsoluteConstraints(580, 90, 140, 30));

        jPanel5.setBackground(new java.awt.Color(204, 204, 204));
        jPanel5.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        jLabel3.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel3.setText("IVA 21%");

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout
                .setHorizontalGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(jPanel5Layout.createSequentialGroup().addContainerGap()
                                .addComponent(jLabel3, javax.swing.GroupLayout.DEFAULT_SIZE, 56, Short.MAX_VALUE)
                                .addContainerGap()));
        jPanel5Layout.setVerticalGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
                        jPanel5Layout.createSequentialGroup().addContainerGap().addComponent(jLabel3,
                                javax.swing.GroupLayout.DEFAULT_SIZE, 25, Short.MAX_VALUE)));

        getContentPane().add(jPanel5, new org.netbeans.lib.awtextra.AbsoluteConstraints(470, 80, 80, 40));

        jPanel6.setBackground(new java.awt.Color(204, 204, 204));
        jPanel6.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel2.setText("UNIDADES");

        javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6);
        jPanel6.setLayout(jPanel6Layout);
        jPanel6Layout.setHorizontalGroup(jPanel6Layout
                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel6Layout.createSequentialGroup().addComponent(jLabel2,
                        javax.swing.GroupLayout.PREFERRED_SIZE, 66, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(0, 0, Short.MAX_VALUE)));
        jPanel6Layout.setVerticalGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
                        jPanel6Layout.createSequentialGroup().addGap(0, 11, Short.MAX_VALUE).addComponent(jLabel2,
                                javax.swing.GroupLayout.PREFERRED_SIZE, 25,
                                javax.swing.GroupLayout.PREFERRED_SIZE)));

        getContentPane().add(jPanel6, new org.netbeans.lib.awtextra.AbsoluteConstraints(380, 80, 70, 40));

        jPanel7.setBackground(new java.awt.Color(204, 204, 204));
        jPanel7.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel1.setText("PRECIO");

        javax.swing.GroupLayout jPanel7Layout = new javax.swing.GroupLayout(jPanel7);
        jPanel7.setLayout(jPanel7Layout);
        jPanel7Layout
                .setHorizontalGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
                                jPanel7Layout.createSequentialGroup().addContainerGap()
                                        .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE,
                                                javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                        .addContainerGap()));
        jPanel7Layout.setVerticalGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
                        jPanel7Layout.createSequentialGroup().addContainerGap().addComponent(jLabel1,
                                javax.swing.GroupLayout.DEFAULT_SIZE, 25, Short.MAX_VALUE)));

        getContentPane().add(jPanel7, new org.netbeans.lib.awtextra.AbsoluteConstraints(300, 80, 60, 40));

        jPanel8.setBackground(new java.awt.Color(204, 204, 204));
        jPanel8.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        javax.swing.GroupLayout jPanel8Layout = new javax.swing.GroupLayout(jPanel8);
        jPanel8.setLayout(jPanel8Layout);
        jPanel8Layout.setHorizontalGroup(jPanel8Layout
                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 156, Short.MAX_VALUE));
        jPanel8Layout.setVerticalGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGap(0, 36, Short.MAX_VALUE));

        getContentPane().add(jPanel8, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 80, 160, 40));

        jPanel9.setBackground(new java.awt.Color(204, 204, 204));
        jPanel9.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        jButtonPrecioTotal.setText("PRECIO TOTAL");
        jButtonPrecioTotal.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonPrecioTotalActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel9Layout = new javax.swing.GroupLayout(jPanel9);
        jPanel9.setLayout(jPanel9Layout);
        jPanel9Layout
                .setHorizontalGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(jPanel9Layout.createSequentialGroup().addContainerGap(19, Short.MAX_VALUE)
                                .addComponent(jButtonPrecioTotal)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(jTextFieldTotalPrice, javax.swing.GroupLayout.PREFERRED_SIZE, 112,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addContainerGap()));
        jPanel9Layout.setVerticalGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel9Layout.createSequentialGroup().addContainerGap()
                        .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(jButtonPrecioTotal).addComponent(jTextFieldTotalPrice,
                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addContainerGap(12, Short.MAX_VALUE)));

        getContentPane().add(jPanel9, new org.netbeans.lib.awtextra.AbsoluteConstraints(460, 270, 260, 50));

        jPanel10.setBackground(new java.awt.Color(204, 204, 204));
        jPanel10.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        javax.swing.GroupLayout jPanel10Layout = new javax.swing.GroupLayout(jPanel10);
        jPanel10.setLayout(jPanel10Layout);
        jPanel10Layout.setHorizontalGroup(jPanel10Layout
                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 100, Short.MAX_VALUE));
        jPanel10Layout.setVerticalGroup(jPanel10Layout
                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 46, Short.MAX_VALUE));

        getContentPane().add(jPanel10, new org.netbeans.lib.awtextra.AbsoluteConstraints(320, 30, -1, 50));

        jButtonVersion.setFont(new java.awt.Font("Trebuchet MS", 0, 11)); // NOI18N
        jButtonVersion.setText("Acerca de");
        jButtonVersion.setBorder(null);
        jButtonVersion.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonVersionActionPerformed(evt);
            }
        });
        getContentPane().add(jButtonVersion, new org.netbeans.lib.awtextra.AbsoluteConstraints(660, 320, 60, -1));

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jButtonPrecioTotalActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonPrecioTotalActionPerformed
        /*Inroducimos un sonido para que se reproduzca a la hora de realizar 
        la accin del botn.*/
        try {
            Player player = new Player(getClass().getResourceAsStream("/sounds/BubblePo.mp3"));
            player.play();
            player.close();
        } catch (Exception e) {
            System.out.println("Error al reproducir el audio");
        }
        /*Realizamos las distintas operaciones para averiguar el coste total de 
        los productos con su respectivo importe del iva.*/
        final double IVA = 0.21;

        float price = Float.valueOf(jTextFieldPrice.getText());
        int units = Integer.valueOf(jTextFieldUnits.getText());
        float iva = (float) (price * units * IVA);
        NumberFormat ivaFormat = NumberFormat.getCurrencyInstance();
        jTextFieldIva.setText(String.valueOf(ivaFormat.format(iva)));
        float total = ((price * units) + iva);
        NumberFormat amountFormat = NumberFormat.getCurrencyInstance();
        jTextFieldTotal.setText(String.valueOf(amountFormat.format(total)));

        float price1 = Float.valueOf(jTextFieldPrice1.getText());
        int units1 = Integer.valueOf(jTextFieldUnits1.getText());
        float iva1 = (float) (price1 * units1 * IVA);
        NumberFormat ivaFormat1 = NumberFormat.getCurrencyInstance();
        jTextFieldIva1.setText(String.valueOf(ivaFormat1.format(iva1)));
        float total1 = (price1 * units1) + iva1;
        NumberFormat amountFormat1 = NumberFormat.getCurrencyInstance();
        jTextFieldTotal1.setText(String.valueOf(amountFormat1.format(total1)));

        float price2 = Float.valueOf(jTextFieldPrice2.getText());
        int units2 = Integer.valueOf(jTextFieldUnits2.getText());
        float iva2 = (float) (price2 * units2 * IVA);
        NumberFormat ivaFormat2 = NumberFormat.getCurrencyInstance();
        jTextFieldIva2.setText(String.valueOf(ivaFormat2.format(iva2)));
        float total2 = (price2 * units2) + iva2;
        NumberFormat amountFormat2 = NumberFormat.getCurrencyInstance();
        jTextFieldTotal2.setText(String.valueOf(amountFormat2.format(total2)));

        float price3 = Float.valueOf(jTextFieldPrice3.getText());
        int units3 = Integer.valueOf(jTextFieldUnits3.getText());
        float iva3 = (float) (price3 * units3 * IVA);
        NumberFormat ivaFormat3 = NumberFormat.getCurrencyInstance();
        jTextFieldIva3.setText(String.valueOf(ivaFormat3.format(iva3)));
        float total3 = (price3 * units3) + iva3;
        NumberFormat amountFormat3 = NumberFormat.getCurrencyInstance();
        jTextFieldTotal3.setText(String.valueOf(amountFormat3.format(total3)));

        //Con esto tenemos la suma total de todos los precios.
        float totalEuros = total + total1 + total2 + total3;
        NumberFormat totalFormat = NumberFormat.getCurrencyInstance();
        jTextFieldTotalPrice.setText(String.valueOf(totalFormat.format(totalEuros)));

        EmailValidator emailValidator = EmailValidator.getInstance();
        boolean emailValid = emailValidator.isValid(jTextFieldEmail.getText());
        String mensaje = emailValid ? "Email vlido" : "Email no vlido";
        System.out.println(mensaje);
    }//GEN-LAST:event_jButtonPrecioTotalActionPerformed

    private void jButtonPayActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonPayActionPerformed
        //Reproducimos un sonido a la hora de realizar la accion del boton.
        try {
            Player player = new Player(getClass().getResourceAsStream("/sounds/pop.mp3"));
            player.play();
            player.close();
        } catch (Exception e) {
            System.out.println("Error al reproducir el audio");
        }
        //Realizamos esto para obtener una ventana emergente.
        int DEFAULT_OPTION = 0;
        int WARNING_MESSAGE = 0;
        JOptionPane.showConfirmDialog(this, "Desear efectuar la compra?", "Pago Contra-reembolso", DEFAULT_OPTION,
                WARNING_MESSAGE);

    }//GEN-LAST:event_jButtonPayActionPerformed

    private void jButtonPayWithCardActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonPayWithCardActionPerformed
        //Volvemos a reproducir el mismo sonido a la hora de realizar la accion del boton.
        try {
            Player player = new Player(getClass().getResourceAsStream("/sounds/pop.mp3"));
            player.play();
            player.close();
        } catch (Exception e) {
            System.out.println("Error al reproducir el audio");
        }
        new Window2(this, true).setVisible(true);
    }//GEN-LAST:event_jButtonPayWithCardActionPerformed

    private void jButtonVersionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonVersionActionPerformed
        new Window1(this, true).setVisible(true);
    }//GEN-LAST:event_jButtonVersionActionPerformed

    /**
     * @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(Facture.class.getName()).log(java.util.logging.Level.SEVERE, null,
                    ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(Facture.class.getName()).log(java.util.logging.Level.SEVERE, null,
                    ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(Facture.class.getName()).log(java.util.logging.Level.SEVERE, null,
                    ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(Facture.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 Facture().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButtonPay;
    private javax.swing.JButton jButtonPayWithCard;
    private javax.swing.JButton jButtonPrecioTotal;
    private javax.swing.JButton jButtonVersion;
    private com.toedter.calendar.JDateChooser jDateChooser1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JLabel jLabelClient;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel10;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanel6;
    private javax.swing.JPanel jPanel7;
    private javax.swing.JPanel jPanel8;
    private javax.swing.JPanel jPanel9;
    private javax.swing.JTextField jTextField1;
    private javax.swing.JTextField jTextField2;
    private javax.swing.JTextField jTextFieldEmail;
    private javax.swing.JTextField jTextFieldIva;
    private javax.swing.JTextField jTextFieldIva1;
    private javax.swing.JTextField jTextFieldIva2;
    private javax.swing.JTextField jTextFieldIva3;
    private javax.swing.JTextField jTextFieldIva4;
    private javax.swing.JTextField jTextFieldIva5;
    private javax.swing.JTextField jTextFieldIva6;
    private javax.swing.JTextField jTextFieldIva7;
    private javax.swing.JTextField jTextFieldPrice;
    private javax.swing.JTextField jTextFieldPrice1;
    private javax.swing.JTextField jTextFieldPrice2;
    private javax.swing.JTextField jTextFieldPrice3;
    private javax.swing.JTextField jTextFieldTotal;
    private javax.swing.JTextField jTextFieldTotal1;
    private javax.swing.JTextField jTextFieldTotal2;
    private javax.swing.JTextField jTextFieldTotal3;
    private javax.swing.JTextField jTextFieldTotalPrice;
    private javax.swing.JTextField jTextFieldUnits;
    private javax.swing.JTextField jTextFieldUnits1;
    private javax.swing.JTextField jTextFieldUnits2;
    private javax.swing.JTextField jTextFieldUnits3;
    // End of variables declaration//GEN-END:variables
}