<file_sep>package view.Empreededor;

import java.awt.Dimension;
import java.awt.Toolkit;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.JFrame;

public final class Alterar extends JFrame{
    //Instancia
    private static Alterar instancia;
    
    //Variáveis do JFrame
    private javax.swing.JButton alterarLoja;
    private javax.swing.JButton alterarProduto;
    private javax.swing.JPanel jPanel1;
    
    //Singleton
    private Alterar(){
        initComponents();
    }
    
    public static Alterar getInstance(){
        if(instancia == null)
            instancia = new Alterar();
        return instancia;
    }
    
    //Eventos
    private void alterarProdutoActionPerformed(java.awt.event.ActionEvent evt) {                                               
    }                                              

    private void alterarLojaActionPerformed(java.awt.event.ActionEvent evt) {                                            
        AlterarLoja.getInstance().setVisible(true);
        instancia.setVisible(false);
    }
    
    //Inicia os componentes
    private void initComponents() {
        
        Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
        this.setLocation(dim.width/2-this.getSize().width/2, dim.height/2-this.getSize().height/2);
        

        jPanel1 = new javax.swing.JPanel();
        alterarProduto = new javax.swing.JButton();
        alterarLoja = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        addWindowListener(new WindowAdapter(){
            @Override
            public void windowClosing(WindowEvent we){
                Alterar.getInstance().setVisible(false);
                Plataforma.getInstance().setVisible(true);
            }
        });
        setTitle("Alterar");

        alterarProduto.setText("Alterar dados de um produto");
        alterarProduto.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                alterarProdutoActionPerformed(evt);
            }
        });

        alterarLoja.setText("Alterar dados da loja");
        alterarLoja.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                alterarLojaActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(64, 64, 64)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(alterarProduto, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(alterarLoja, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap(71, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap(60, Short.MAX_VALUE)
                .addComponent(alterarProduto, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(39, 39, 39)
                .addComponent(alterarLoja, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(53, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
        );

        pack();
    }
    
}
<file_sep>package view.Cliente;

import controller.LojaDAO;
import controller.ProdutoDAO;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import model.Endereco;
import model.Loja;
import model.Produto;
import view.ControladorDeJanelas;
import view.Exceptions.GUIException;
import view.Exceptions.InvalidTextException;

public class ClienteConsultaEspecifica extends JFrame{
    //Instancia do singleton
    private static ClienteConsultaEspecifica instancia;
    
    //Variáveis do JFrame
    private javax.swing.JTextField cityTextField;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTable jTable1;
    private javax.swing.JTextField neighbourTextField;
    private javax.swing.JTextField pesquisaTextField;
    private javax.swing.JButton searchButton;
    
    //Singleton
    private ClienteConsultaEspecifica(){
        initComponents();
    }
    
    public static ClienteConsultaEspecifica getInstance(){
        if(instancia == null){
            instancia = new ClienteConsultaEspecifica();
        }
        return instancia;
    }
    
    //Eventos
    private void searchButtonActionPerformed(java.awt.event.ActionEvent evt) throws InvalidTextException {                                             
        ArrayList<Produto> produtos = new ArrayList<>();
        ArrayList<Produto> produtos_validos = new ArrayList<>();
        String nome_produto_busca;
        String cidade;
        String bairro;
        Loja loja;
        ArrayList<Integer> lojas;
        
        ControladorDeJanelas.clearRows(jTable1);
        
        try{
            //Captura os dados dos text fields
            nome_produto_busca = ControladorDeJanelas.getTextField(pesquisaTextField);
            cidade = ControladorDeJanelas.getTextField(cityTextField);
            bairro = ControladorDeJanelas.getTextField(neighbourTextField);
            
            //Captura todos os produtos com o nome no campo do text field
            produtos = ProdutoDAO.obterProdutos(nome_produto_busca);
            
            //Obtem as lojas que possuem aquele produto
            lojas = ProdutoDAO.obterIdLojas(nome_produto_busca);
            
            //Atribui a loja a qual pertence para cada produto
            for(int i = 0; i < produtos.size();i++){
                loja = LojaDAO.obterLoja(lojas.get(i));
                produtos.get(i).setLoja(loja);
            }
            
            //Separa os produtos que são válidos
            for(int i = 0; i < produtos.size();i++){
                Produto produto_atual = produtos.get(i);
                Loja loja_atual = produto_atual.getLoja();
                Endereco endereco_atual = loja_atual.getEndereco();
                
                if((endereco_atual.getBairro().compareTo(bairro)) == 0 && 
                   (endereco_atual.getCidade().compareTo(cidade)) == 0)
                {
                    produtos_validos.add(produto_atual);
                }
            }
            
            if(produtos_validos.size() == 0){
                JOptionPane.showMessageDialog(null, "Nenhum produto encontrado", "Lamentamos", JOptionPane.INFORMATION_MESSAGE);
            }else{
                ControladorDeJanelas.fillTableEspecifica(jTable1, produtos_validos);
            }
        }catch(InvalidTextException e){
            new GUIException(e.getMessage());
        }    
    }                                            

    private void pesquisaTextFieldActionPerformed(java.awt.event.ActionEvent evt) throws InvalidTextException {                                                  
        searchButtonActionPerformed(evt);
    }                                                 

    private void cityTextFieldActionPerformed(java.awt.event.ActionEvent evt) throws InvalidTextException {                                              
        searchButtonActionPerformed(evt);
    }                                             

    private void neighbourTextFieldActionPerformed(java.awt.event.ActionEvent evt) throws InvalidTextException {                                                   
        searchButtonActionPerformed(evt);
    }
    
    //Inicia os componentes
    private void initComponents() {
        
        Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
        this.setLocation(dim.width/2-this.getSize().width/2, dim.height/2-this.getSize().height/2);
        
        setTitle("Consulta por bairro");
        
        jScrollPane1 = new javax.swing.JScrollPane();
        jTable1 = new javax.swing.JTable();
        pesquisaTextField = new javax.swing.JTextField();
        pesquisaTextField.setName("pesquisa");
        
        searchButton = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        cityTextField = new javax.swing.JTextField();
        cityTextField.setName("cidade");
        
        neighbourTextField = new javax.swing.JTextField();
        neighbourTextField.setName("bairro");
        
        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        
        addWindowListener(new WindowAdapter(){
            @Override
            public void windowClosing(WindowEvent we){
                cityTextField.setText("");
                neighbourTextField.setText("");
                pesquisaTextField.setText("");
                instancia.setVisible(false);
                PonteCliente.getInstance().setVisible(true);
                ControladorDeJanelas.clearRows(jTable1);
            }
        });
        
        jTable1.setAutoCreateRowSorter(true);
        jTable1.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Nome:", "Quantidade:", "Preço:", "Loja:"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class
            };
            boolean[] canEdit = new boolean [] {
                false, false, false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jScrollPane1.setViewportView(jTable1);

        pesquisaTextField.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                try {
                    pesquisaTextFieldActionPerformed(evt);
                } catch (InvalidTextException ex) {
                    Logger.getLogger(ClienteConsultaEspecifica.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
        });

        searchButton.setText("Procurar");
        searchButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                try {
                    searchButtonActionPerformed(evt);
                } catch (InvalidTextException ex) {
                    Logger.getLogger(ClienteConsultaEspecifica.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
        });

        jLabel1.setText("Digite o nome do produto que deseja buscar:");

        jLabel2.setText("Em qual bairro deseja buscar ?");

        jLabel3.setText("Em qual cidade deseja buscar ?");

        cityTextField.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                try {
                    cityTextFieldActionPerformed(evt);
                } catch (InvalidTextException ex) {
                    Logger.getLogger(ClienteConsultaEspecifica.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
        });

        neighbourTextField.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                try {
                    neighbourTextFieldActionPerformed(evt);
                } catch (InvalidTextException ex) {
                    Logger.getLogger(ClienteConsultaEspecifica.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(27, 27, 27)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 520, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                .addComponent(neighbourTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 354, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(36, 36, 36))
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                .addComponent(jLabel2)
                                .addGap(150, 150, 150))
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                    .addComponent(cityTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 354, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addGap(36, 36, 36))
                                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                    .addComponent(jLabel3)
                                    .addGap(147, 147, 147))
                                .addGroup(layout.createSequentialGroup()
                                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addComponent(pesquisaTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 354, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addComponent(jLabel1))
                                    .addGap(36, 36, 36))))
                        .addComponent(searchButton, javax.swing.GroupLayout.PREFERRED_SIZE, 132, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(28, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(22, 22, 22)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(pesquisaTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jLabel3)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(cityTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jLabel2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(neighbourTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(searchButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 42, Short.MAX_VALUE)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 205, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        pack();
    }                       

    
}
<file_sep>package view.Exceptions;

import javax.swing.JOptionPane;

public class GUIException {
    
    /**
    * Exibe uma tela de exceção com o texto "text"
    * @param    text Texto a ser exibo na GUI de erro
    */
    public GUIException(String text){
        JOptionPane.showMessageDialog(null, text, "Erro", JOptionPane.WARNING_MESSAGE,null);
    }
    
}
<file_sep>package view.Cliente;

import controller.*;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import model.Produto;
import view.ControladorDeJanelas;
import view.Exceptions.GUIException;
import view.Exceptions.InvalidTextException;

public class ClienteConsultaGeral extends JFrame{
    //Variáveis do JFrame
    private javax.swing.JLabel jLabel1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTable jTable1;
    private javax.swing.JTextField pesquisaTextField;
    private javax.swing.JButton searchButton;
    
    //Instancia Singleton
    private static ClienteConsultaGeral instancia;
    
    //Singleton
    private ClienteConsultaGeral(){
        initComponents();
    }
    
    public static ClienteConsultaGeral getInstance(){
        if(instancia == null)
            instancia = new ClienteConsultaGeral();
        return instancia;
    }
    
    //Eventos
    private void searchButtonActionPerformed(java.awt.event.ActionEvent evt) throws InvalidTextException, SQLException {                                             
        try{
            ControladorDeJanelas.clearRows(jTable1);
            String query;
            ArrayList<Produto> produtos = new ArrayList<>();
            query = ControladorDeJanelas.getTextField(pesquisaTextField);
            produtos = ProdutoDAO.obterProdutos(query);
            if(produtos.size() <= 0){
                JOptionPane.showMessageDialog(null, "Nenhum produto encontrado!", "Lamentamos", JOptionPane.WARNING_MESSAGE);
            }else{
                ControladorDeJanelas.fillTableGeral(jTable1, produtos);
            }
        }catch(InvalidTextException e){
            new GUIException(e.getMessage());
        }    
    }                                            

    private void pesquisaTextFieldActionPerformed(java.awt.event.ActionEvent evt) throws InvalidTextException, SQLException {                                                  
        searchButtonActionPerformed(evt);
    }
    
    //Inicia os componentes
    private void initComponents() {
        
        Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
        this.setLocation(dim.width/2-this.getSize().width/2, dim.height/2-this.getSize().height/2);
        

        jScrollPane1 = new javax.swing.JScrollPane();
        jTable1 = new javax.swing.JTable();
        pesquisaTextField = new javax.swing.JTextField();
        pesquisaTextField.setName("pesquisa");
        searchButton = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        
        setTitle("Consulta");
        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        addWindowListener(new WindowAdapter(){
            @Override
            public void windowClosing(WindowEvent we){
                PonteCliente.getInstance().setVisible(true);
                ControladorDeJanelas.clearRows(jTable1);
                pesquisaTextField.setText("");
                instancia.setVisible(false);
            }
        });
        
        jTable1.setAutoCreateRowSorter(true);
        jTable1.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Nome:", "Quantidade:", "Preço:", "Loja:"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class
            };
            boolean[] canEdit = new boolean [] {
                false, false, false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jScrollPane1.setViewportView(jTable1);

        pesquisaTextField.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                try {
                    pesquisaTextFieldActionPerformed(evt);
                } catch (InvalidTextException ex) {
                    Logger.getLogger(ClienteConsultaGeral.class.getName()).log(Level.SEVERE, null, ex);
                } catch (SQLException ex) {
                    Logger.getLogger(ClienteConsultaGeral.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
        });

        searchButton.setText("Procurar");
        searchButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                try {
                    searchButtonActionPerformed(evt);
                } catch (InvalidTextException ex) {
                    Logger.getLogger(ClienteConsultaGeral.class.getName()).log(Level.SEVERE, null, ex);
                } catch (SQLException ex) {
                    Logger.getLogger(ClienteConsultaGeral.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
        });

        jLabel1.setText("Digite o nome do produto que deseja buscar:");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(27, 27, 27)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addComponent(pesquisaTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 354, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel1))
                        .addGap(62, 62, 62)
                        .addComponent(searchButton, javax.swing.GroupLayout.PREFERRED_SIZE, 104, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 520, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(37, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(22, 22, 22)
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(pesquisaTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(searchButton))
                .addGap(26, 26, 26)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 205, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(39, Short.MAX_VALUE))
        );

        pack();
    }
    
}
<file_sep>package view.Empreededor;

import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.JFrame;
import model.*;
import controller.*;
import java.awt.Dimension;
import java.awt.Toolkit;
import javax.swing.JOptionPane;
import view.ControladorDeJanelas;
import view.Exceptions.GUIException;
import view.Exceptions.InvalidTextException;
import view.RoundedBorder;

public final class CadastroNovaLoja extends JFrame{
    //Instância do Singleton
    private static CadastroNovaLoja instancia;
    
    //Construtor
    private CadastroNovaLoja(){
        initComponents();
    }
    
    public static CadastroNovaLoja getInstance(){
        if(instancia == null){
            instancia = new CadastroNovaLoja();
        }
        
        return instancia;
    }
    
    
    //Variáveis do JFrame
    private javax.swing.JTextField bairroTextField;
    private javax.swing.JButton cadastrarNovaLoja;
    private javax.swing.JTextField cidadeTextField;
    private javax.swing.JTextField cnpjTextField;
    private javax.swing.JTextField estadoTextField;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JTextField razaoSocialTextField;
    private javax.swing.JTextField ruaTextField;
    private javax.swing.JPasswordField senhaTextField;
    
    
    //Inicia os componentes
    private void initComponents() {
        
        Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
        this.setLocation(dim.width/2-this.getSize().width/2, dim.height/2-this.getSize().height/2);
        
        cnpjTextField = new javax.swing.JTextField();
        cnpjTextField.setName("cnpj");
        
        razaoSocialTextField = new javax.swing.JTextField();
        razaoSocialTextField.setName("razão social");
        
        senhaTextField = new javax.swing.JPasswordField();
        senhaTextField.setName("senha");
        
        ruaTextField = new javax.swing.JTextField();
        ruaTextField.setName("rua");
        
        bairroTextField = new javax.swing.JTextField();
        bairroTextField.setName("bairro");
        
        cidadeTextField = new javax.swing.JTextField();
        cidadeTextField.setName("cidade");
        
        estadoTextField = new javax.swing.JTextField();
        estadoTextField.setName("estado");
        
        
        cadastrarNovaLoja = new javax.swing.JButton();
        cadastrarNovaLoja.setBorder(new RoundedBorder(20));

        
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        
        
        
        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        addWindowListener(new WindowAdapter(){
            @Override
            public void windowClosing(WindowEvent we){
                cnpjTextField.setText("");
                senhaTextField.setText("");
                ruaTextField.setText("");
                bairroTextField.setText("");
                estadoTextField.setText("");
                cidadeTextField.setText("");
                razaoSocialTextField.setText("");
                Login.clearPasswordField();
                Login.getInstance().setVisible(true);
            }
        });
        setTitle("Cadastrar nova loja");
        
        jLabel1.setFont(new java.awt.Font("Lucida Grande", 0, 14)); // NOI18N
        jLabel1.setText("Digite o cnpj da empresa (somente números):");

        jLabel2.setFont(new java.awt.Font("Lucida Grande", 0, 14)); // NOI18N
        jLabel2.setText("Informe a sua senha:");

        jLabel3.setFont(new java.awt.Font("Lucida Grande", 0, 14)); // NOI18N
        jLabel3.setText("Informações sobre o endereço:");

        jLabel4.setFont(new java.awt.Font("Lucida Grande", 0, 14)); // NOI18N
        jLabel4.setText("Rua:");

        jLabel5.setFont(new java.awt.Font("Lucida Grande", 0, 14)); // NOI18N
        jLabel5.setText("Bairro:");

        jLabel6.setFont(new java.awt.Font("Lucida Grande", 0, 14)); // NOI18N
        jLabel6.setText("Cidade:");

        jLabel7.setFont(new java.awt.Font("Lucida Grande", 0, 14)); // NOI18N
        jLabel7.setText("Estado:");

        jLabel8.setFont(new java.awt.Font("Lucida Grande", 0, 14)); // NOI18N
        jLabel8.setText("Informe a razão social:");

        cnpjTextField.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt){
                try{
                    cnpjTextFieldActionPerformed(evt);
                }catch(InvalidTextException e){
                    System.out.println(e.getMessage());
                } catch (CNPJException ex) {
                    System.out.println(ex.getMessage());
                }
            }
        });

        razaoSocialTextField.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                try {
                    razaoSocialTextFieldActionPerformed(evt);
                } catch (InvalidTextException ex) {
                    System.out.println(ex.getMessage());
                } catch (CNPJException ex) {
                    System.out.println(ex.getMessage());
                }
            }
        });

        senhaTextField.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                try {
                    senhaTextFieldActionPerformed(evt);
                } catch (InvalidTextException ex) {
                    System.out.println(ex.getMessage());
                } catch (CNPJException ex) {
                    System.out.println(ex.getMessage());
                }
            }
        });

        ruaTextField.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                try {
                    ruaTextFieldActionPerformed(evt);
                } catch (InvalidTextException ex) {
                    System.out.println(ex.getMessage());
                } catch (CNPJException ex) {
                    System.out.println(ex.getMessage());
                }
            }
        });

        bairroTextField.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                try {
                    bairroTextFieldActionPerformed(evt);
                } catch (InvalidTextException ex) {
                    System.out.println(ex.getMessage());
                } catch (CNPJException ex) {
                    System.out.println(ex.getMessage());
                }
            }
        });

        cidadeTextField.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                try {
                    cidadeTextFieldActionPerformed(evt);
                } catch (InvalidTextException ex) {
                    System.out.println(ex.getMessage());
                } catch (CNPJException ex) {
                    System.out.println(ex.getMessage());
                }
            }
        });

        estadoTextField.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                try {
                    estadoTextFieldActionPerformed(evt);
                } catch (InvalidTextException ex) {
                    System.out.println(ex.getMessage());
                } catch (CNPJException ex) {
                
                }
            }
        });

        jLabel9.setFont(new java.awt.Font("Lucida Grande", 0, 36)); // NOI18N
        jLabel9.setText("Cadastro");

        cadastrarNovaLoja.setFont(new java.awt.Font("Lucida Grande", 0, 24)); // NOI18N
        cadastrarNovaLoja.setText("Cadastrar");
        cadastrarNovaLoja.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                try{
                    cadastrarNovaLojaActionPerformed(evt);
                }catch(InvalidTextException e){
                    System.out.println(e);
                } catch (CNPJException ex) {
                    System.out.println(ex);
                }
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(38, 38, 38)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                .addComponent(jLabel2)
                                .addComponent(jLabel8)
                                .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(jLabel3)
                                .addComponent(razaoSocialTextField)
                                .addComponent(cnpjTextField)
                                .addComponent(senhaTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 323, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGroup(layout.createSequentialGroup()
                                    .addGap(47, 47, 47)
                                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addComponent(ruaTextField)
                                        .addComponent(bairroTextField)
                                        .addGroup(layout.createSequentialGroup()
                                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                .addComponent(jLabel6)
                                                .addComponent(jLabel5)
                                                .addComponent(jLabel4)
                                                .addComponent(jLabel7))
                                            .addGap(0, 0, Short.MAX_VALUE))
                                        .addComponent(cidadeTextField, javax.swing.GroupLayout.Alignment.TRAILING)
                                        .addComponent(estadoTextField))))
                            .addGroup(layout.createSequentialGroup()
                                .addGap(99, 99, 99)
                                .addComponent(jLabel9))))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(97, 97, 97)
                        .addComponent(cadastrarNovaLoja, javax.swing.GroupLayout.PREFERRED_SIZE, 227, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(84, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(21, 21, 21)
                .addComponent(jLabel9)
                .addGap(18, 18, 18)
                .addComponent(jLabel8)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(razaoSocialTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel1)
                .addGap(7, 7, 7)
                .addComponent(cnpjTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jLabel2)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(senhaTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jLabel3)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel4)
                .addGap(5, 5, 5)
                .addComponent(ruaTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel5)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(bairroTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel6)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(cidadeTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel7)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(estadoTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(cadastrarNovaLoja, javax.swing.GroupLayout.PREFERRED_SIZE, 74, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(22, Short.MAX_VALUE))
        );

        pack();
    }
    
    
    //Eventos
    private void senhaTextFieldActionPerformed(java.awt.event.ActionEvent evt)throws InvalidTextException,CNPJException {                                               
        cadastrarNovaLojaActionPerformed(evt);
    }                                              

    private void razaoSocialTextFieldActionPerformed(java.awt.event.ActionEvent evt) throws InvalidTextException,CNPJException{                                                     
        cadastrarNovaLojaActionPerformed(evt);
    }                                                    

    private void cnpjTextFieldActionPerformed(java.awt.event.ActionEvent evt) throws InvalidTextException,CNPJException {                                              
        cadastrarNovaLojaActionPerformed(evt);
    }                                             

    private void ruaTextFieldActionPerformed(java.awt.event.ActionEvent evt) throws InvalidTextException,CNPJException{                                             
        cadastrarNovaLojaActionPerformed(evt);
    }                                            

    private void bairroTextFieldActionPerformed(java.awt.event.ActionEvent evt) throws InvalidTextException,CNPJException {                                                
        cadastrarNovaLojaActionPerformed(evt);
    }                                               
    
    private void cidadeTextFieldActionPerformed(java.awt.event.ActionEvent evt) throws InvalidTextException,CNPJException {                                                
        cadastrarNovaLojaActionPerformed(evt);
    }                                               

    private void estadoTextFieldActionPerformed(java.awt.event.ActionEvent evt) throws InvalidTextException,CNPJException {                                                
        cadastrarNovaLojaActionPerformed(evt);
    }                                               

    /**
    * Cadastra uma nova loja inserido esta no banco de dados
    * @param evt Evento que será acionado
    * @throws InvalidTextException e CNPJ Exception
    */
    private void cadastrarNovaLojaActionPerformed(java.awt.event.ActionEvent evt) throws InvalidTextException,CNPJException{                                                  
        Endereco end;
        Loja loja;
        boolean flag = false;
        try{
            String razao_social = ControladorDeJanelas.getTextField(razaoSocialTextField);
            String cnpj = ControladorDeJanelas.getTextField(cnpjTextField);
            String rua = ControladorDeJanelas.getTextField(ruaTextField);
            String bairro = ControladorDeJanelas.getTextField(bairroTextField);
            String cidade = ControladorDeJanelas.getTextField(cidadeTextField);
            String estado = ControladorDeJanelas.getTextField(estadoTextField);
            String senha = String.valueOf(ControladorDeJanelas.getTextField(senhaTextField).hashCode());
            
            Loja.validarCNPJ(cnpj);
            
            end = new Endereco(rua,bairro,cidade,estado);
            loja = new Loja(razao_social,cnpj,senha,end);
            
            LojaDAO.createLoja(loja);
            flag = true;
      	}catch(CNPJException e){
            new GUIException(e.getMessage());
      	}catch(InvalidTextException e){
            new GUIException(e.getMessage());
        }
      	if(flag){
            JOptionPane.showMessageDialog(null, "Loja criada com sucesso!\nVocê já pode logar em sua conta", "Sucesso", JOptionPane.INFORMATION_MESSAGE);
            
            instancia.setVisible(false);
            Login.getInstance().setVisible(true);

            instancia.bairroTextField.setText("");
            instancia.cidadeTextField.setText("");
            instancia.cnpjTextField.setText("");
            instancia.estadoTextField.setText("");
            instancia.razaoSocialTextField.setText("");
            instancia.ruaTextField.setText("");
            instancia.senhaTextField.setText("");
        }
    }
    
}
<file_sep>package model;

public class CNPJException extends Exception{
    
    CNPJException(String s){
        super(s);    
    }
    
}
<file_sep>package model;

import controller.ProdutoDAO;
import model.Endereco;
import java.util.ArrayList;

public class Loja {
    private int id;
    private String razaoSocial;
    private String cnpj;
    private String senha;
    private Endereco endereco;

    private ArrayList<Produto> produtos = new ArrayList<>();

    //construtor
    public Loja(){};

    public Loja(String razaoSocial, String cnpj, String senha, Endereco endereco){
            this.razaoSocial = razaoSocial;
            this.cnpj = cnpj;
            this.senha = senha;
            this.endereco = endereco;
    }
    
    /**
    * Método que valida um CNPJ
    * @param cnpj CNPJ que será validado
    * @throws CNPJException - Lança a exceção de CNPJ inválido caso ele seja.
    */
    public static void validarCNPJ(String cnpj) throws CNPJException{
        if(cnpj.length() != 14)
            throw new CNPJException("O cnpj digitado não possui um formato válido");
        
        int[] primeira_etapa = {5,4,3,2,9,8,7,6,5,4,3,2};// 12 digitos
        int[] segunda_etapa = {6,5,4,3,2,9,8,7,6,5,4,3,2};// 13 digitos
        int primeiro_digito = 0;
        int segundo_digito = 0;
        //Calculo do primeiro digito
        for(int i = 0; i < 12;i++){
            primeiro_digito += (Integer.parseInt(Character.toString(cnpj.charAt(i)))*primeira_etapa[i]);
        }
        primeiro_digito %= 11;
        
        if(primeiro_digito < 2){
            primeiro_digito = 0;
        }else{
            primeiro_digito = 11 - primeiro_digito;
        }
        //Fim do cálculo do primeiro digito
        
        //Calculo do segudo dígito
        for(int i = 0; i < 13; i ++){
            segundo_digito += (Integer.parseInt(Character.toString(cnpj.charAt(i)))*segunda_etapa[i]);
        }
        
        segundo_digito %= 11;
        
        if(segundo_digito < 2){
            segundo_digito = 0;
        }else{
            segundo_digito = 11 - segundo_digito;
        }
        
        //Fim do cálculo do segundo dígito
        
        
        //Verificando se o CNPJ é válido
        if(Integer.parseInt(Character.toString(cnpj.charAt(12))) != primeiro_digito ||
           Integer.parseInt(Character.toString(cnpj.charAt(13))) != segundo_digito)
        {
            throw new CNPJException("O CNPJ informado não é válido");
            
        }
        
    }
    
    /**
    * Preenche a lista de produtos de uma determinada loja
    */
    public void preencherProdutos(){
        produtos.clear();
        this.produtos = ProdutoDAO.obterProdutos(this.id);
    }

    //setters e getters
    public void setId(int id){
        this.id = id;
    }
    public int getId(){
        return this.id;
    }
    public void setRazaoSocial(String razaoSocial){
        this.razaoSocial = razaoSocial;
    }
    public String getRazaoSocial(){
        return this.razaoSocial;
    }    
    public String getCnpj() {
        return cnpj;
    }

    public void setCnpj(String cnpj) {
        this.cnpj = cnpj;
    }

    public String getSenha() {
        return senha;
    }

    public void setSenha(String senha) {
        this.senha = senha;
    }
    public void setEndereco(Endereco endereco){
        this.endereco = endereco;
    }   
    public Endereco getEndereco(){
        return this.endereco;
    }
    
    public ArrayList<Produto> getProdutos(){
        return produtos;
    }
    
}
<file_sep><h1> Trabalho POO 2018</h1>
<p>
  Participantes do grupo: <NAME> e <NAME>.</br>
  Cenário 1.
</p>
