calzaii.CalzaII.java Source code

Java tutorial

Introduction

Here is the source code for calzaii.CalzaII.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 calzaii;

import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLEncoder;
import java.util.HashMap;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.DefaultListModel;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
import org.apache.commons.net.ftp.FTP;
import org.apache.commons.net.ftp.FTPClient;

/**
 *
 * @author xurxo
 */
public class CalzaII extends javax.swing.JFrame {

    private DefaultListModel listaZapatos;
    private DefaultListModel listaOfertas;
    private String servidor;
    private String userftp;
    private String passftp;
    private String rutaAbsoluta;
    private HashMap<String, String> zapatos;

    public CalzaII() {
        try {
            initComponents();

            servidor = "url";
            userftp = "user";
            passftp = "pass";
            zapatos = new HashMap<>();

            //Introducir lista de zapatos en HashMap
            URL url = new URL("http://" + servidor + "/consultar.php");
            URLConnection consulta = url.openConnection();
            BufferedReader modelos = new BufferedReader(new InputStreamReader(consulta.getInputStream()));

            String[] zapato;
            String[] imagen;
            while ((zapato = modelos.readLine().split(";")) != null && !zapato[0].isEmpty()) {
                imagen = zapato[1].split("/");
                zapatos.put(zapato[0], imagen[4] + "/" + imagen[5]);
            }

            listaZapatos = new DefaultListModel();
            jList1.setModel(listaZapatos);

            listaOfertas = new DefaultListModel();
            jList2.setModel(listaOfertas);

        } catch (MalformedURLException ex) {
            Logger.getLogger(CalzaII.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IOException ex) {
            Logger.getLogger(CalzaII.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

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

        jTabbedPane1 = new javax.swing.JTabbedPane();
        jPanel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jTextField1 = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        jTextField2 = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        jTextField3 = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        jTextField4 = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        jComboBox2 = new javax.swing.JComboBox();
        jButton2 = new javax.swing.JButton();
        jLabel6 = new javax.swing.JLabel();
        jPanel2 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jList1 = new javax.swing.JList();
        jComboBox1 = new javax.swing.JComboBox();
        jPanel3 = new javax.swing.JPanel();
        jLabel7 = new javax.swing.JLabel();
        jTextField5 = new javax.swing.JTextField();
        jPanel4 = new javax.swing.JPanel();
        jScrollPane2 = new javax.swing.JScrollPane();
        jList2 = new javax.swing.JList();
        jButton1 = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jTabbedPane1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jTabbedPane1MouseClicked(evt);
            }
        });

        jLabel1.setText("Modelo:");

        jLabel2.setText("Tallas:");

        jLabel3.setText("Imagen:");

        jTextField3.setEditable(false);

        jLabel4.setText("Precio:");

        jLabel5.setText("Tipo:");

        jComboBox2.setModel(
                new javax.swing.DefaultComboBoxModel(new String[] { "Nio", "Nia", "Hombre", "Mujer" }));

        jButton2.setText("Abrir");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        jLabel6.setText("");

        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.LEADING)
                        .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGroup(
                                        jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                .addComponent(jLabel1).addComponent(jLabel2))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addGroup(
                                        jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                .addComponent(jTextField1).addComponent(jTextField2)))
                        .addGroup(jPanel1Layout.createSequentialGroup().addComponent(jLabel3)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jTextField3, javax.swing.GroupLayout.DEFAULT_SIZE, 362,
                                        Short.MAX_VALUE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(jButton2))
                        .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGroup(
                                        jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                .addComponent(jLabel4).addComponent(jLabel5))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addGroup(jPanel1Layout
                                        .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addComponent(jComboBox2, 0, javax.swing.GroupLayout.DEFAULT_SIZE,
                                                Short.MAX_VALUE)
                                        .addGroup(jPanel1Layout.createSequentialGroup().addComponent(jTextField4)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                .addComponent(jLabel6)))))
                        .addContainerGap()));
        jPanel1Layout.setVerticalGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel1Layout.createSequentialGroup().addGap(27, 27, 27)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(jLabel1).addComponent(jTextField1,
                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(jLabel2).addComponent(jTextField2,
                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(jLabel3)
                                .addComponent(jTextField3, javax.swing.GroupLayout.PREFERRED_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jButton2))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(jLabel4)
                                .addComponent(jTextField4, javax.swing.GroupLayout.PREFERRED_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jLabel6))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(jComboBox2, javax.swing.GroupLayout.PREFERRED_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jLabel5))
                        .addContainerGap(84, Short.MAX_VALUE)));

        jTabbedPane1.addTab("Insertar/Modificar", jPanel1);

        jScrollPane1.setViewportView(jList1);

        jComboBox1.setModel(
                new javax.swing.DefaultComboBoxModel(new String[] { "Nio", "Nia", "Hombre", "Mujer" }));
        jComboBox1.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                jComboBox1ItemStateChanged(evt);
            }
        });

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(jPanel2Layout
                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 535, Short.MAX_VALUE)
                .addGroup(jPanel2Layout.createSequentialGroup().addGap(56, 56, 56)
                        .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
        jPanel2Layout.setVerticalGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 205, Short.MAX_VALUE)
                        .addContainerGap()));

        jTabbedPane1.addTab("Eliminar", jPanel2);

        jLabel7.setText("Descripcin de la oferta: ");

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(jPanel3Layout
                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel3Layout.createSequentialGroup().addContainerGap()
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jTextField5).addGroup(jPanel3Layout.createSequentialGroup()
                                        .addComponent(jLabel7).addGap(0, 333, Short.MAX_VALUE)))
                        .addContainerGap()));
        jPanel3Layout
                .setVerticalGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(jPanel3Layout.createSequentialGroup().addGap(24, 24, 24).addComponent(jLabel7)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(jTextField5, javax.swing.GroupLayout.PREFERRED_SIZE, 27,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addContainerGap(187, Short.MAX_VALUE)));

        jTabbedPane1.addTab("Insertar Oferta", jPanel3);

        jList2.setModel(new javax.swing.AbstractListModel() {
            String[] strings = { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" };

            public int getSize() {
                return strings.length;
            }

            public Object getElementAt(int i) {
                return strings[i];
            }
        });
        jScrollPane2.setViewportView(jList2);

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(jPanel4Layout
                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel4Layout.createSequentialGroup().addContainerGap()
                        .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 511, Short.MAX_VALUE)
                        .addContainerGap()));
        jPanel4Layout.setVerticalGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel4Layout.createSequentialGroup().addContainerGap()
                        .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 241, Short.MAX_VALUE)
                        .addContainerGap()));

        jTabbedPane1.addTab("Eliminar Oferta", jPanel4);

        jButton1.setText("Confirmar");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        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()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jTabbedPane1)
                                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                        .addGap(0, 0, Short.MAX_VALUE).addComponent(jButton1)))
                        .addContainerGap()));
        layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup().addContainerGap().addComponent(jTabbedPane1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jButton1).addContainerGap()));

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

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
    try {
        URLConnection connection;
        InputStream response;
        String tipo;
        String precio;

        switch (jTabbedPane1.getSelectedIndex()) {
            case 0:
                if (!jTextField1.getText().isEmpty() && !jTextField2.getText().isEmpty() && !jTextField3.getText().isEmpty() && !jTextField4.getText().isEmpty()) {
                    tipo = (String) jComboBox2.getSelectedItem();
                    tipo = tipo.toLowerCase();
                    tipo = tipo.replace('', 'n');

                    precio = (String) jTextField4.getText();
                    precio = precio.replace(',', '.');

                    //Eliminar a imaxe do servidor se algn zapato existente e modificado
                    boolean eliminado = true;
                    if (zapatos.get(jTextField1.getText()) != null) {
                        FTPClient ftp = new FTPClient();
                        ftp.connect(servidor);
                        ftp.login(userftp, passftp);
                        eliminado = ftp.deleteFile("/public_html/fotos/" + zapatos.get(jTextField1.getText()));
                        ftp.disconnect();
                    }

                    if (eliminado) {
                        //Subir Foto FTP
                        String urlftp = "ftp://%s:%s@%s/%s;type=i";
                        urlftp = String.format(urlftp, userftp, passftp, servidor, "/public_html/fotos/" + tipo + "/" + jTextField3.getText() + ".jpeg");
                        connection = new URL(urlftp).openConnection();
                        OutputStream outputStream = connection.getOutputStream();
                        FileInputStream fileInputStream = new FileInputStream(rutaAbsoluta);

                        byte[] buffer = new byte[4096];
                        int bytesRead = -1;
                        while ((bytesRead = fileInputStream.read(buffer)) != -1) {
                            outputStream.write(buffer, 0, bytesRead);
                        }

                        fileInputStream.close();
                        outputStream.close();

                        //Subir Zapato a Base de Datos
                        connection = new URL("http://" + servidor + "/insertar.php?modelo=" + URLEncoder.encode(jTextField1.getText(),"UTF-8") + "&tallas=" + URLEncoder.encode(jTextField2.getText(),"UTF-8") + "&imagen=" + URLEncoder.encode(jTextField3.getText(),"UTF-8") + "&precio=" + precio + "&tipo=" + tipo).openConnection();
                        response = connection.getInputStream();

                        zapatos.put(jTextField1.getText(), tipo + "/" + jTextField3.getText() + ".jpeg");

                        jTextField1.setText("");
                        jTextField2.setText("");
                        jTextField3.setText("");
                        jTextField4.setText("");

                        JOptionPane.showMessageDialog(null, "Unidad insertada correctamente.");
                    } else {
                        JOptionPane.showMessageDialog(null, "Erro na modificacin do producto!");

                    }

                } else {
                    JOptionPane.showMessageDialog(null, "Falta algn dato por aadir!");
                }

                break;
            case 1:
                try {
                    tipo = (String) jComboBox1.getSelectedItem();
                    tipo = tipo.toLowerCase();
                    tipo = tipo.replace('', 'n');

                    //Borrar Imaxe
                    FTPClient ftp = new FTPClient();

                    ftp.connect(servidor);
                    ftp.login(userftp, passftp);

                    boolean eliminado = ftp.deleteFile("/public_html/fotos/" + zapatos.get(jList1.getSelectedValue()));

                    if (eliminado) {
                        connection = new URL("http://" + servidor + "/eliminar.php?modelo=" + URLEncoder.encode((String) jList1.getSelectedValue(), "UTF-8")).openConnection();
                        response = connection.getInputStream();

                        zapatos.remove(jList1.getSelectedIndex());
                        listaZapatos.remove(jList1.getSelectedIndex());
                    } else {
                        JOptionPane.showMessageDialog(null, "Erro ao eliminar o modelo!");
                    }

                    ftp.disconnect();
                } catch (IOException ex) {
                    JOptionPane.showMessageDialog(null, "Erro na operacion Entrada/Saida.");
                    Logger.getLogger(CalzaII.class.getName()).log(Level.SEVERE, null, ex);
                }
                break;
            case 2:
                connection = new URL("http://" + servidor + "/insertarOferta.php?descripcion=" + URLEncoder.encode(jTextField5.getText(),"UTF-8")).openConnection();
                response = connection.getInputStream();
                jTextField5.setText("");
                JOptionPane.showMessageDialog(null, "Oferta insertada correctamente.");
                break;
            case 3:
                connection = new URL("http://" + servidor + "/eliminarOferta.php?descripcion=" + URLEncoder.encode((String) jList2.getSelectedValue(), "UTF-8")).openConnection();
                response = connection.getInputStream();
                listaOfertas.removeElement(jList2.getSelectedValue());
                break;
        }
    } catch (MalformedURLException ex) {
        JOptionPane.showMessageDialog(null, "Erro na conexon.");
        Logger.getLogger(CalzaII.class.getName()).log(Level.SEVERE, null, ex);
    } catch (IOException ex) {
        JOptionPane.showMessageDialog(null, "Erro na operacion Entrada/Saida.");
        Logger.getLogger(CalzaII.class.getName()).log(Level.SEVERE, null, ex);
    }
}//GEN-LAST:event_jButton1ActionPerformed

private void jTabbedPane1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTabbedPane1MouseClicked
    switch (jTabbedPane1.getSelectedIndex()) {
        case 1:
            zapatos.clear();
            String tipo = (String) jComboBox1.getSelectedItem();
            tipo = tipo.toLowerCase();
            tipo = tipo.replace('', 'n');

            listaZapatos.removeAllElements();
            try {
                URL url = new URL("http://" + servidor + "/consultar.php?tipo=" + tipo);
                URLConnection consulta = url.openConnection();
                BufferedReader modelos = new BufferedReader(new InputStreamReader(consulta.getInputStream()));

                String[] zapato;
                String[] imagen;
                while ((zapato = modelos.readLine().split(";")) != null && !zapato[0].isEmpty()) {
                    imagen = zapato[1].split("/");

                    zapatos.put(zapato[0], imagen[4] + "/" + imagen[5]);
                    listaZapatos.addElement(zapato[0]);
                }

                modelos.close();

            } catch (MalformedURLException ex) {
                JOptionPane.showMessageDialog(null, "Erro na conexon.");
                Logger.getLogger(CalzaII.class.getName()).log(Level.SEVERE, null, ex);
            } catch (IOException ex) {
                JOptionPane.showMessageDialog(null, "Erro na operacion Entrada/Saida.");
                Logger.getLogger(CalzaII.class.getName()).log(Level.SEVERE, null, ex);
            }
            break;
        case 3:
            listaOfertas.removeAllElements();

            try {
                URL url = new URL("http://" + servidor + "/ofertas.php");
                URLConnection consulta = url.openConnection();
                BufferedReader ofertas = new BufferedReader(new InputStreamReader(consulta.getInputStream()));

                String oferta;                    
                while ((oferta = ofertas.readLine()) != null && !oferta.isEmpty()) {
                    listaOfertas.addElement(oferta);
                }

                ofertas.close();

            } catch (MalformedURLException ex) {
                JOptionPane.showMessageDialog(null, "Erro na conexon.");
                Logger.getLogger(CalzaII.class.getName()).log(Level.SEVERE, null, ex);
            } catch (IOException ex) {
                JOptionPane.showMessageDialog(null, "Erro na operacion Entrada/Saida.");
                Logger.getLogger(CalzaII.class.getName()).log(Level.SEVERE, null, ex);
            }
            break;
    }
}//GEN-LAST:event_jTabbedPane1MouseClicked

private void jComboBox1ItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jComboBox1ItemStateChanged
    try {
        zapatos.clear();
        String tipo = (String) jComboBox1.getSelectedItem();
        tipo = tipo.toLowerCase();
        tipo = tipo.replace('', 'n');

        URL url = new URL("http://" + servidor + "/consultar.php?tipo=" + tipo);
        URLConnection consulta = url.openConnection();
        BufferedReader modelos = new BufferedReader(new InputStreamReader(consulta.getInputStream()));

        String[] zapato;
        String[] imagen;
        while ((zapato = modelos.readLine().split(";")) != null && !zapato[0].isEmpty()) {
            imagen = zapato[1].split("/");

            zapatos.put(zapato[0], imagen[4] + "/" + imagen[5]);
            listaZapatos.addElement(zapato[0]);
        }

        modelos.close();

    } catch (MalformedURLException ex) {
        JOptionPane.showMessageDialog(null, "Erro na conexon.");
        Logger.getLogger(CalzaII.class.getName()).log(Level.SEVERE, null, ex);
    } catch (IOException ex) {
        JOptionPane.showMessageDialog(null, "Erro na operacion Entrada/Saida.");
        Logger.getLogger(CalzaII.class.getName()).log(Level.SEVERE, null, ex);
    }
}//GEN-LAST:event_jComboBox1ItemStateChanged

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        SelImagen selImagen = new SelImagen(this);
        selImagen.setVisible(true);
    }//GEN-LAST:event_jButton2ActionPerformed

    public void setRutaAbsoluta(String rutaAbsoluta) {
        this.rutaAbsoluta = rutaAbsoluta;
    }

    public JTextField getjTextField3() {
        return jTextField3;
    }

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

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JComboBox jComboBox1;
    private javax.swing.JComboBox jComboBox2;
    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.JList jList1;
    private javax.swing.JList jList2;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JTextField jTextField1;
    private javax.swing.JTextField jTextField2;
    private javax.swing.JTextField jTextField3;
    private javax.swing.JTextField jTextField4;
    private javax.swing.JTextField jTextField5;
    // End of variables declaration//GEN-END:variables
}