Java tutorial
/* * 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 visao; import com.itextpdf.text.Document; import com.itextpdf.text.DocumentException; import com.itextpdf.text.PageSize; import com.itextpdf.text.Paragraph; import com.itextpdf.text.pdf.PdfWriter; import controle.AgendamentoCtrl; import controle.AnimalCtrl; import controle.ClienteCtrl; import static controle.Util.reduzString; import java.awt.Dimension; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.logging.Level; import java.util.logging.Logger; import javax.swing.DefaultListModel; import javax.swing.ImageIcon; import javax.swing.JList; import javax.swing.JOptionPane; import modelo.Agendamento; import modelo.Animal; import modelo.Cliente; /** * * @author Dcio */ public class TelaConsultaAgendamento extends javax.swing.JInternalFrame { public static String rgCliente, nomeCliente; private DefaultListModel lista = new DefaultListModel(); private static ArrayList listaNome, listaAnimal, arrayListAnimal; private static int pos = 0, tam = 0; //private String idCliente, nomeCliente; private List lAnimal; private JList listAnimal; private String urlMiniFoto, nomeAnimal; private static int openFrameCount = 0; //teste private static final int xOffset = 30, yOffset = 30; //teste private Object a; /** * Creates new form TelaRelatorioCliente */ public TelaConsultaAgendamento() { super("Document #" + (++openFrameCount), true, //resizable true, //closable true, //maximizable true);//iconifiable initComponents(); /* this.setLocation(50, 100); //(ponto inicial apartir lateral,altura) setLocation(xOffset*openFrameCount, yOffset*openFrameCount); this.repaint(); idCliente = ""; nomeCliente = ""; tctPetAnimalCpfCliente.setEditable(false); tctIdCliente.setEditable(false); */ //populaJComboBoxClientesNome(); btnListarPet.setEnabled(false); tctCpfCliente.setEditable(false); tctIdCliente.setEditable(false); //Limpar ComboBox cbxNomePet.removeAllItems(); cbxNomePet.setSelectedIndex(-1); /*String url = System.getProperty("user.dir") + "\\src\\Icones\\clientePet.jpg";*/ String url = System.getProperty("user.dir") + "\\ImagensPet\\petDono.jpg"; colocarFotoLabelUrl(url); tctCpfCliente.setText(""); tctCpfCliente.setEditable(false); tctIdCliente.setText(""); tctIdCliente.setEditable(false); desabilitarBotoesCliente(); desabilitarBotoesRelPet(); txtRelPet.setText(""); } /** * 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() { PainelRelTituloCliente = new javax.swing.JPanel(); lblTituloRelatorioPet = new javax.swing.JLabel(); lblTelaRelatorioCliente = new javax.swing.JLabel(); PanelRelClientesBotoes = new javax.swing.JPanel(); btnLimparTelaPetRel = new javax.swing.JButton(); btnSairRelPet = new javax.swing.JButton(); btnImprimirRelatorioPet = new javax.swing.JButton(); PanelTabRelPetImpresso = new javax.swing.JTabbedPane(); PainelRelOpcoesCliente = new javax.swing.JPanel(); lblNomePet = new javax.swing.JLabel(); cbxNomePet = new javax.swing.JComboBox(); btnListarPet = new javax.swing.JButton(); btnListarTodosPets = new javax.swing.JButton(); lblTelaPetNomeCliente = new javax.swing.JLabel(); tctNomeCliente = new javax.swing.JTextField(); btnPesquisarCliente = new javax.swing.JButton(); lblTelaPetCodigoCliente = new javax.swing.JLabel(); tctCpfCliente = new javax.swing.JTextField(); lblTelaPetCodigoCliente1 = new javax.swing.JLabel(); jPanelBotoesMovimentoCliente = new javax.swing.JPanel(); btnPrevCli = new javax.swing.JButton(); btnNextCli = new javax.swing.JButton(); btnLastCli = new javax.swing.JButton(); btnInicioCli = new javax.swing.JButton(); tctIdCliente = new javax.swing.JTextField(); PainelRelImpresso = new javax.swing.JPanel(); jScrollPane1 = new javax.swing.JScrollPane(); txtRelPet = new javax.swing.JTextArea(); lblFotoPetRel = new javax.swing.JLabel(); lblRelatorioPetImagem = new javax.swing.JLabel(); addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { formMouseClicked(evt); } }); getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout()); PainelRelTituloCliente .setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(153, 153, 153))); lblTituloRelatorioPet.setFont(new java.awt.Font("Times New Roman", 3, 24)); // NOI18N lblTituloRelatorioPet.setForeground(new java.awt.Color(102, 102, 102)); lblTituloRelatorioPet.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); lblTituloRelatorioPet.setText("Petfast - Pet"); lblTelaRelatorioCliente .setIcon(new javax.swing.ImageIcon(getClass().getResource("/Icones/pessoaFisica.jpeg"))); // NOI18N javax.swing.GroupLayout PainelRelTituloClienteLayout = new javax.swing.GroupLayout(PainelRelTituloCliente); PainelRelTituloCliente.setLayout(PainelRelTituloClienteLayout); PainelRelTituloClienteLayout.setHorizontalGroup( PainelRelTituloClienteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(PainelRelTituloClienteLayout.createSequentialGroup().addGap(246, 246, 246) .addComponent(lblTelaRelatorioCliente).addGap(67, 67, 67) .addComponent(lblTituloRelatorioPet, javax.swing.GroupLayout.PREFERRED_SIZE, 232, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(441, Short.MAX_VALUE))); PainelRelTituloClienteLayout.setVerticalGroup(PainelRelTituloClienteLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, PainelRelTituloClienteLayout.createSequentialGroup().addContainerGap() .addGroup(PainelRelTituloClienteLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(lblTelaRelatorioCliente, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(lblTituloRelatorioPet, javax.swing.GroupLayout.DEFAULT_SIZE, 42, Short.MAX_VALUE)) .addContainerGap())); getContentPane().add(PainelRelTituloCliente, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 10, 1020, -1)); PanelRelClientesBotoes.setBorder(javax.swing.BorderFactory.createTitledBorder("")); btnLimparTelaPetRel.setBackground(new java.awt.Color(204, 204, 204)); btnLimparTelaPetRel.setFont(new java.awt.Font("Times New Roman", 1, 14)); // NOI18N btnLimparTelaPetRel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Icones/oopsRed.png"))); // NOI18N btnLimparTelaPetRel.setText("Limpar"); btnLimparTelaPetRel.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); btnLimparTelaPetRel.setMargin(new java.awt.Insets(0, 0, 0, 0)); btnLimparTelaPetRel.setPreferredSize(new java.awt.Dimension(100, 50)); btnLimparTelaPetRel.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnLimparTelaPetRelActionPerformed(evt); } }); btnSairRelPet.setBackground(new java.awt.Color(204, 204, 204)); btnSairRelPet.setFont(new java.awt.Font("Times New Roman", 1, 14)); // NOI18N btnSairRelPet.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Icones/saidaDireitaRed.png"))); // NOI18N btnSairRelPet.setText("Voltar"); btnSairRelPet.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); btnSairRelPet.setMargin(new java.awt.Insets(0, 0, 0, 0)); btnSairRelPet.setPreferredSize(new java.awt.Dimension(100, 50)); btnSairRelPet.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnSairRelPetActionPerformed(evt); } }); btnImprimirRelatorioPet.setBackground(new java.awt.Color(204, 204, 204)); btnImprimirRelatorioPet.setFont(new java.awt.Font("Times New Roman", 1, 14)); // NOI18N btnImprimirRelatorioPet .setIcon(new javax.swing.ImageIcon(getClass().getResource("/Icones/infraero/pdf2.png"))); // NOI18N btnImprimirRelatorioPet.setText("Imprimir em PDF"); btnImprimirRelatorioPet.setToolTipText("Salvar Alteraes"); btnImprimirRelatorioPet.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); btnImprimirRelatorioPet.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT); btnImprimirRelatorioPet.setIconTextGap(2); btnImprimirRelatorioPet.setMargin(new java.awt.Insets(0, 0, 0, 0)); btnImprimirRelatorioPet.setPreferredSize(new java.awt.Dimension(100, 50)); btnImprimirRelatorioPet.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnImprimirRelatorioPetActionPerformed(evt); } }); javax.swing.GroupLayout PanelRelClientesBotoesLayout = new javax.swing.GroupLayout(PanelRelClientesBotoes); PanelRelClientesBotoes.setLayout(PanelRelClientesBotoesLayout); PanelRelClientesBotoesLayout.setHorizontalGroup(PanelRelClientesBotoesLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, PanelRelClientesBotoesLayout .createSequentialGroup().addGap(28, 28, 28) .addComponent(btnLimparTelaPetRel, javax.swing.GroupLayout.PREFERRED_SIZE, 129, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 142, Short.MAX_VALUE) .addComponent(btnImprimirRelatorioPet, javax.swing.GroupLayout.PREFERRED_SIZE, 171, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(59, 59, 59).addComponent(btnSairRelPet, javax.swing.GroupLayout.PREFERRED_SIZE, 127, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap())); PanelRelClientesBotoesLayout.setVerticalGroup(PanelRelClientesBotoesLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(PanelRelClientesBotoesLayout.createSequentialGroup().addContainerGap() .addGroup(PanelRelClientesBotoesLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(btnSairRelPet, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(btnImprimirRelatorioPet, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(btnLimparTelaPetRel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); getContentPane().add(PanelRelClientesBotoes, new org.netbeans.lib.awtextra.AbsoluteConstraints(280, 460, 670, -1)); PainelRelOpcoesCliente .setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(153, 153, 153))); lblNomePet.setFont(new java.awt.Font("Times New Roman", 3, 14)); // NOI18N lblNomePet.setText("Nome Pet: "); cbxNomePet.setFont(new java.awt.Font("Arial", 3, 12)); // NOI18N cbxNomePet.addItemListener(new java.awt.event.ItemListener() { public void itemStateChanged(java.awt.event.ItemEvent evt) { cbxNomePetItemStateChanged(evt); } }); cbxNomePet.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { cbxNomePetActionPerformed(evt); } }); btnListarPet.setFont(new java.awt.Font("Arial", 1, 12)); // NOI18N btnListarPet.setMnemonic('E'); btnListarPet.setText("Agendamentos do Pet"); btnListarPet.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnListarPetActionPerformed(evt); } }); btnListarTodosPets.setFont(new java.awt.Font("Arial", 1, 12)); // NOI18N btnListarTodosPets.setText("Agendamentos Cliente"); btnListarTodosPets.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnListarTodosPetsActionPerformed(evt); } }); lblTelaPetNomeCliente.setBackground(new java.awt.Color(102, 102, 102)); lblTelaPetNomeCliente.setFont(new java.awt.Font("Times New Roman", 3, 14)); // NOI18N lblTelaPetNomeCliente.setText("Cliente:"); tctNomeCliente.setBackground(new java.awt.Color(255, 239, 191)); tctNomeCliente.setFont(new java.awt.Font("Arial", 1, 18)); // NOI18N tctNomeCliente.setForeground(new java.awt.Color(51, 51, 51)); tctNomeCliente.setHorizontalAlignment(javax.swing.JTextField.LEFT); btnPesquisarCliente.setBackground(new java.awt.Color(235, 245, 130)); btnPesquisarCliente.setFont(new java.awt.Font("Tahoma", 3, 10)); // NOI18N btnPesquisarCliente.setForeground(new java.awt.Color(0, 0, 51)); btnPesquisarCliente.setText("Pesquisar"); btnPesquisarCliente.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnPesquisarClienteActionPerformed(evt); } }); lblTelaPetCodigoCliente.setBackground(new java.awt.Color(102, 102, 102)); lblTelaPetCodigoCliente.setFont(new java.awt.Font("Times New Roman", 3, 14)); // NOI18N lblTelaPetCodigoCliente.setText("Cpf:"); tctCpfCliente.setBackground(new java.awt.Color(255, 239, 191)); tctCpfCliente.setFont(new java.awt.Font("Arial", 1, 18)); // NOI18N tctCpfCliente.setForeground(new java.awt.Color(51, 51, 51)); tctCpfCliente.setHorizontalAlignment(javax.swing.JTextField.LEFT); lblTelaPetCodigoCliente1.setBackground(new java.awt.Color(102, 102, 102)); lblTelaPetCodigoCliente1.setFont(new java.awt.Font("Times New Roman", 3, 14)); // NOI18N lblTelaPetCodigoCliente1.setText("Id Cliente:"); jPanelBotoesMovimentoCliente.setName("PainelBotoes"); // NOI18N btnPrevCli.setBackground(new java.awt.Color(235, 245, 130)); btnPrevCli.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N btnPrevCli.setForeground(new java.awt.Color(0, 0, 51)); btnPrevCli.setText("<"); btnPrevCli.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnPrevCliActionPerformed(evt); } }); btnNextCli.setBackground(new java.awt.Color(235, 245, 130)); btnNextCli.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N btnNextCli.setForeground(new java.awt.Color(0, 0, 51)); btnNextCli.setText(">"); btnNextCli.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnNextCliActionPerformed(evt); } }); btnLastCli.setBackground(new java.awt.Color(235, 245, 130)); btnLastCli.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N btnLastCli.setForeground(new java.awt.Color(0, 0, 51)); btnLastCli.setText(">|"); btnLastCli.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnLastCliActionPerformed(evt); } }); btnInicioCli.setBackground(new java.awt.Color(235, 245, 130)); btnInicioCli.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N btnInicioCli.setForeground(new java.awt.Color(0, 0, 51)); btnInicioCli.setText("|<"); btnInicioCli.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnInicioCliActionPerformed(evt); } }); javax.swing.GroupLayout jPanelBotoesMovimentoClienteLayout = new javax.swing.GroupLayout( jPanelBotoesMovimentoCliente); jPanelBotoesMovimentoCliente.setLayout(jPanelBotoesMovimentoClienteLayout); jPanelBotoesMovimentoClienteLayout.setHorizontalGroup( jPanelBotoesMovimentoClienteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanelBotoesMovimentoClienteLayout.createSequentialGroup().addContainerGap() .addComponent(btnInicioCli, javax.swing.GroupLayout.PREFERRED_SIZE, 67, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(btnPrevCli, javax.swing.GroupLayout.PREFERRED_SIZE, 67, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(btnNextCli, javax.swing.GroupLayout.PREFERRED_SIZE, 67, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(btnLastCli, javax.swing.GroupLayout.PREFERRED_SIZE, 67, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); jPanelBotoesMovimentoClienteLayout.setVerticalGroup( jPanelBotoesMovimentoClienteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanelBotoesMovimentoClienteLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(btnPrevCli, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(btnInicioCli, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(jPanelBotoesMovimentoClienteLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(btnLastCli, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(btnNextCli, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE))); tctIdCliente.setEditable(false); tctIdCliente.setBackground(new java.awt.Color(255, 239, 191)); tctIdCliente.setFont(new java.awt.Font("Arial", 1, 18)); // NOI18N javax.swing.GroupLayout PainelRelOpcoesClienteLayout = new javax.swing.GroupLayout(PainelRelOpcoesCliente); PainelRelOpcoesCliente.setLayout(PainelRelOpcoesClienteLayout); PainelRelOpcoesClienteLayout.setHorizontalGroup(PainelRelOpcoesClienteLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(PainelRelOpcoesClienteLayout.createSequentialGroup().addGroup(PainelRelOpcoesClienteLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(PainelRelOpcoesClienteLayout.createSequentialGroup().addGap(10, 10, 10) .addComponent(lblTelaPetCodigoCliente).addGap(29, 29, 29) .addComponent(tctCpfCliente, javax.swing.GroupLayout.PREFERRED_SIZE, 305, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(37, 37, 37).addComponent(lblTelaPetCodigoCliente1).addGap(18, 18, 18) .addComponent(tctIdCliente, javax.swing.GroupLayout.PREFERRED_SIZE, 112, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(PainelRelOpcoesClienteLayout.createSequentialGroup().addGap(10, 10, 10) .addGroup(PainelRelOpcoesClienteLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) .addGroup(PainelRelOpcoesClienteLayout.createSequentialGroup() .addComponent(lblNomePet).addGap(18, 18, 18) .addComponent(cbxNomePet, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(btnListarPet, javax.swing.GroupLayout.PREFERRED_SIZE, 173, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(PainelRelOpcoesClienteLayout.createSequentialGroup() .addComponent(lblTelaPetNomeCliente) .addGroup(PainelRelOpcoesClienteLayout .createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING) .addGroup(PainelRelOpcoesClienteLayout .createSequentialGroup().addGap(10, 10, 10) .addComponent(tctNomeCliente, javax.swing.GroupLayout.PREFERRED_SIZE, 402, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(29, 29, 29) .addComponent(btnPesquisarCliente, javax.swing.GroupLayout.PREFERRED_SIZE, 101, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(PainelRelOpcoesClienteLayout .createSequentialGroup().addGap(61, 61, 61) .addComponent(jPanelBotoesMovimentoCliente, javax.swing.GroupLayout.PREFERRED_SIZE, 300, javax.swing.GroupLayout.PREFERRED_SIZE)))))) .addGroup(PainelRelOpcoesClienteLayout.createSequentialGroup().addContainerGap() .addComponent(btnListarTodosPets, javax.swing.GroupLayout.PREFERRED_SIZE, 210, javax.swing.GroupLayout.PREFERRED_SIZE))) .addGap(63, 63, 63))); PainelRelOpcoesClienteLayout.setVerticalGroup(PainelRelOpcoesClienteLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(PainelRelOpcoesClienteLayout.createSequentialGroup().addGap(23, 23, 23) .addGroup(PainelRelOpcoesClienteLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(tctCpfCliente, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(tctIdCliente, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE) .addGroup(PainelRelOpcoesClienteLayout.createSequentialGroup().addGap(8, 8, 8) .addGroup(PainelRelOpcoesClienteLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(lblTelaPetCodigoCliente) .addComponent(lblTelaPetCodigoCliente1)))) .addGap(27, 27, 27) .addGroup(PainelRelOpcoesClienteLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(PainelRelOpcoesClienteLayout.createSequentialGroup().addGap(8, 8, 8) .addComponent(lblTelaPetNomeCliente)) .addComponent(tctNomeCliente, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE) .addGroup(PainelRelOpcoesClienteLayout.createSequentialGroup().addGap(1, 1, 1) .addComponent(btnPesquisarCliente, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE))) .addGap(5, 5, 5) .addComponent(jPanelBotoesMovimentoCliente, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(26, 26, 26) .addGroup(PainelRelOpcoesClienteLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(PainelRelOpcoesClienteLayout.createSequentialGroup().addGap(2, 2, 2) .addComponent(lblNomePet)) .addGroup(PainelRelOpcoesClienteLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(cbxNomePet, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(btnListarPet))) .addGap(31, 31, 31).addComponent(btnListarTodosPets, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap())); PanelTabRelPetImpresso.addTab("Relatrios Pets", PainelRelOpcoesCliente); txtRelPet.setEditable(false); txtRelPet.setBackground(new java.awt.Color(151, 226, 153)); txtRelPet.setColumns(20); txtRelPet.setFont(new java.awt.Font("Arial", 1, 12)); // NOI18N txtRelPet.setRows(7); txtRelPet.setBorder( javax.swing.BorderFactory.createMatteBorder(1, 1, 1, 1, new java.awt.Color(51, 51, 255))); jScrollPane1.setViewportView(txtRelPet); javax.swing.GroupLayout PainelRelImpressoLayout = new javax.swing.GroupLayout(PainelRelImpresso); PainelRelImpresso.setLayout(PainelRelImpressoLayout); PainelRelImpressoLayout.setHorizontalGroup( PainelRelImpressoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(PainelRelImpressoLayout.createSequentialGroup() .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 770, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(lblFotoPetRel, javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap())); PainelRelImpressoLayout.setVerticalGroup( PainelRelImpressoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(PainelRelImpressoLayout.createSequentialGroup() .addComponent(lblFotoPetRel, javax.swing.GroupLayout.PREFERRED_SIZE, 136, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(0, 176, Short.MAX_VALUE)) .addGroup(PainelRelImpressoLayout.createSequentialGroup().addComponent(jScrollPane1) .addContainerGap())); PanelTabRelPetImpresso.addTab("Relatrio Impresso", PainelRelImpresso); getContentPane().add(PanelTabRelPetImpresso, new org.netbeans.lib.awtextra.AbsoluteConstraints(270, 110, 780, 340)); PanelTabRelPetImpresso.getAccessibleContext().setAccessibleName("Relatrios Pets"); lblRelatorioPetImagem.setText(" "); lblRelatorioPetImagem.setBorder(javax.swing.BorderFactory.createTitledBorder("")); getContentPane().add(lblRelatorioPetImagem, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 100, 230, 400)); pack(); }// </editor-fold>//GEN-END:initComponents private void btnLimparTelaPetRelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnLimparTelaPetRelActionPerformed //Limpar ComboBox cbxNomePet.setSelectedIndex(-1); cbxNomePet.removeAllItems(); tctNomeCliente.setText(""); tctCpfCliente.setText(""); tctCpfCliente.setEditable(false); tctIdCliente.setText(""); tctIdCliente.setEditable(false); desabilitarBotoesCliente(); desabilitarBotoesRelPet(); txtRelPet.setText(""); colocarMiniFotoLabelVaga(); }//GEN-LAST:event_btnLimparTelaPetRelActionPerformed private void btnSairRelPetActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSairRelPetActionPerformed this.dispose(); }//GEN-LAST:event_btnSairRelPetActionPerformed private void btnImprimirRelatorioPetActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnImprimirRelatorioPetActionPerformed //criamos um documento vazio String msg = ""; String tituloMsg = "Relatrio PDF"; String passagemTexto = txtRelPet.getText(); Document documento = new Document(); try { try { //criar o documento no diretrio do projeto Netbeans AeroFast PdfWriter.getInstance(documento, new FileOutputStream("RelatriosPdf\\documentoPetfastClientes.pdf")); } catch (FileNotFoundException ex) { msg = msg + ex; msg = reduzString(msg); Logger.getLogger(TelaConsultaAgendamento.class.getName()).log(Level.SEVERE, null, ex); } //abrir o documento criado. documento.open(); //ajustar o tamanho da pagina documento.setPageSize(PageSize.A4); //Adicionar um paragrafo documento.add(new Paragraph(passagemTexto)); } catch (DocumentException ex) { msg = msg + ex; msg = reduzString(msg); Logger.getLogger(FrameListaCliente.class.getName()).log(Level.SEVERE, null, ex); } finally { documento.close(); if (!"".equals(msg)) { JOptionPane.showMessageDialog(this, msg, tituloMsg, JOptionPane.WARNING_MESSAGE); msg = ""; } else { msg = "Relatrio criado em PDF com sucesso"; JOptionPane.showMessageDialog(this, msg, tituloMsg, JOptionPane.WARNING_MESSAGE); msg = ""; } } }//GEN-LAST:event_btnImprimirRelatorioPetActionPerformed private void cbxNomePetItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cbxNomePetItemStateChanged /* if (cbxNomePet.isValid()) { ClienteCtrl cCliente = new ClienteCtrl(); String nomeCliente = cbxNomePet.getSelectedItem().toString(); System.out.println(nomeCliente); Cliente cliNome = cCliente.buscarClientesPorNome(nomeCliente); tctCpfCliente.setText(cliNome.getCpf()); System.out.println(cliNome.getNome()); System.out.println(cliNome.getCpf()); System.out.println(cliNome.getIdCliente()); tctNomeCliente.setText(cliNome.getNome()); tctIdCliente.setText(cliNome.getIdCliente()); } */ }//GEN-LAST:event_cbxNomePetItemStateChanged private void cbxNomePetActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbxNomePetActionPerformed if ((cbxNomePet.getSelectedIndex()) != -1) { btnListarPet.setEnabled(true); } else { btnListarPet.setEnabled(false); } }//GEN-LAST:event_cbxNomePetActionPerformed private void btnListarTodosPetsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnListarTodosPetsActionPerformed String title = "Agendamentos Cliente"; /* int id = Integer.parseInt(tctIdCliente.getText()); AnimalCtrl cAnimal = new AnimalCtrl(); PanelTabRelPetImpresso.setSelectedIndex(1); List animal; animal = cAnimal.receberListaAnimaisCliente(id); this.carregarListaAnimal2(animal); */ String id = tctIdCliente.getText(); AgendamentoCtrl agendaCtrl = new AgendamentoCtrl(); PanelTabRelPetImpresso.setSelectedIndex(1); List agendamento; agendamento = agendaCtrl.listarAgendamentoClienteCtrl(id); this.carregarListaAgendamentoCliente(agendamento); }//GEN-LAST:event_btnListarTodosPetsActionPerformed private void btnPesquisarClienteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnPesquisarClienteActionPerformed // Pesquisar Cliente e buscar lista animais por cliente int idClienteP; ClienteCtrl ccliente = new ClienteCtrl(); listaNome = (ArrayList) ccliente.listaClientesPorNome(tctNomeCliente.getText()); if (!listaNome.isEmpty()) { habilitarBotoesRelPet(); pos = 0; tam = listaNome.size() - 1; Cliente cli = (Cliente) listaNome.get(0); //preenche os dados do cliente no form tctCpfCliente.setText(cli.getCpf()); tctNomeCliente.setText(cli.getNome()); tctIdCliente.setText(cli.getIdCliente()); idClienteP = Integer.parseInt(cli.getIdCliente()); habilitarBotoesCliente(); populaJComboBoxAnimalCliente(idClienteP); // colocarMiniFotoLabel(); } else { JOptionPane.showMessageDialog(null, "Cliente no localizado!"); tctCpfCliente.setText(""); tctNomeCliente.setText(""); tctIdCliente.setText(""); cbxNomePet.setSelectedItem(null); cbxNomePet.setSelectedIndex(-1); cbxNomePet.removeAllItems(); cbxNomePet.removeAll(); desabilitarBotoesCliente(); } /* */ }//GEN-LAST:event_btnPesquisarClienteActionPerformed private void btnInicioCliActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnInicioCliActionPerformed // Boto [|<] System.out.println("Boto [|<]"); int idClienteP; pos = 0; Cliente cli = (Cliente) listaNome.get(pos); tctCpfCliente.setText(cli.getCpf()); tctNomeCliente.setText(cli.getNome()); tctIdCliente.setText(cli.getIdCliente()); idClienteP = Integer.parseInt(cli.getIdCliente()); populaJComboBoxAnimalCliente(idClienteP); //colocarMiniFotoLabel(); //btnIncluirPet.setEnabled(true); }//GEN-LAST:event_btnInicioCliActionPerformed private void btnPrevCliActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnPrevCliActionPerformed // Boto [<] System.out.println("Boto [<]"); if (pos > 0) { int idClienteP; pos--; Cliente cli = (Cliente) listaNome.get(pos); tctCpfCliente.setText(cli.getCpf()); tctNomeCliente.setText(cli.getNome()); tctIdCliente.setText(cli.getIdCliente()); idClienteP = Integer.parseInt(cli.getIdCliente()); populaJComboBoxAnimalCliente(idClienteP); // colocarMiniFotoLabel(); //btnIncluirPet.setEnabled(true); } }//GEN-LAST:event_btnPrevCliActionPerformed private void btnNextCliActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnNextCliActionPerformed // Boto [>] System.out.println("Boto [>]"); if (pos < tam) { int idClienteP; pos++; Cliente cli = (Cliente) listaNome.get(pos); tctCpfCliente.setText(cli.getCpf()); tctNomeCliente.setText(cli.getNome()); tctIdCliente.setText(cli.getIdCliente()); idClienteP = Integer.parseInt(cli.getIdCliente()); populaJComboBoxAnimalCliente(idClienteP); //colocarMiniFotoLabel(); //btnIncluirPet.setEnabled(true); } }//GEN-LAST:event_btnNextCliActionPerformed private void btnLastCliActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnLastCliActionPerformed // Boto [>|] System.out.println("Boto [>|]"); int idClienteP; pos = tam; Cliente cli = (Cliente) listaNome.get(tam); tctCpfCliente.setText(cli.getCpf()); tctNomeCliente.setText(cli.getNome()); tctIdCliente.setText(cli.getIdCliente()); idClienteP = Integer.parseInt(cli.getIdCliente()); populaJComboBoxAnimalCliente(idClienteP); //colocarMiniFotoLabel(); //btnIncluirPet.setEnabled(true); }//GEN-LAST:event_btnLastCliActionPerformed private void formMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_formMouseClicked toFront(); }//GEN-LAST:event_formMouseClicked private void btnListarPetActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnListarPetActionPerformed String id = tctIdCliente.getText(); AgendamentoCtrl agendaCtrl = new AgendamentoCtrl(); PanelTabRelPetImpresso.setSelectedIndex(1); List agendamento; agendamento = agendaCtrl.listarAgendamentoClienteCtrl(id); this.carregarListaAgendamentoCliente(agendamento); }//GEN-LAST:event_btnListarPetActionPerformed // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JPanel PainelRelImpresso; private javax.swing.JPanel PainelRelOpcoesCliente; private javax.swing.JPanel PainelRelTituloCliente; private javax.swing.JPanel PanelRelClientesBotoes; private javax.swing.JTabbedPane PanelTabRelPetImpresso; private javax.swing.JButton btnImprimirRelatorioPet; private javax.swing.JButton btnInicioCli; private javax.swing.JButton btnLastCli; private javax.swing.JButton btnLimparTelaPetRel; private javax.swing.JButton btnListarPet; private javax.swing.JButton btnListarTodosPets; private javax.swing.JButton btnNextCli; private javax.swing.JButton btnPesquisarCliente; private javax.swing.JButton btnPrevCli; private javax.swing.JButton btnSairRelPet; private javax.swing.JComboBox cbxNomePet; private javax.swing.JPanel jPanelBotoesMovimentoCliente; private javax.swing.JScrollPane jScrollPane1; private javax.swing.JLabel lblFotoPetRel; private javax.swing.JLabel lblNomePet; private javax.swing.JLabel lblRelatorioPetImagem; private javax.swing.JLabel lblTelaPetCodigoCliente; private javax.swing.JLabel lblTelaPetCodigoCliente1; private javax.swing.JLabel lblTelaPetNomeCliente; private javax.swing.JLabel lblTelaRelatorioCliente; private javax.swing.JLabel lblTituloRelatorioPet; private static javax.swing.JTextField tctCpfCliente; private javax.swing.JTextField tctIdCliente; private static javax.swing.JTextField tctNomeCliente; private javax.swing.JTextArea txtRelPet; // End of variables declaration//GEN-END:variables private void colocarFotoLabelUrl(String urlFoto) { lblRelatorioPetImagem.setIcon(null); Dimension d = lblRelatorioPetImagem.getSize(); int width = lblRelatorioPetImagem.getWidth() - 20; int height = lblRelatorioPetImagem.getHeight() - 20; ImageIcon foto; foto = new ImageIcon(urlFoto); foto.setImage(foto.getImage().getScaledInstance(250, 400, 100)); //foto.setImage(foto.getImage().getScaledInstance((d.width - 20), (d.height - 20), 100)); lblRelatorioPetImagem.setIcon(foto); } private void desabilitarBotoesRelPet() { btnListarPet.setEnabled(false); btnListarTodosPets.setEnabled(false); } private void habilitarBotoesRelPet() { btnListarPet.setEnabled(true); btnListarTodosPets.setEnabled(true); } private void desabilitarBotoesCliente() { btnInicioCli.setEnabled(false); btnPrevCli.setEnabled(false); btnNextCli.setEnabled(false); btnLastCli.setEnabled(false); } private void habilitarBotoesCliente() { btnInicioCli.setEnabled(true); btnPrevCli.setEnabled(true); btnNextCli.setEnabled(true); btnLastCli.setEnabled(true); } private void populaJComboBoxAnimalCliente(int id) { AnimalCtrl cAnimal = new AnimalCtrl(); cbxNomePet.removeAllItems(); //remove os itens atuais do comboBox. listaAnimal = cAnimal.populaComboAnimaisCliente(id); //retorna os animais do cliente. Iterator i = listaAnimal.iterator(); while (i.hasNext()) { cbxNomePet.addItem(String.valueOf(i.next())); } } private void carregarListaAnimal2(List<Animal> ListaAnimais) { String newline = System.getProperty("line.separator"); //verificar propriedades de System.getProperty String resultado = ""; String sexoAnimal = ""; String nomeCliente = ""; ClienteCtrl cliente = new ClienteCtrl(); //for (Cliente c : ListaClientes) { for (Animal a : ListaAnimais) { nomeCliente = cliente.buscarNomeId(a.getIdCliente()); resultado += "" + "\n\tCdigo Cliente: " + a.getIdCliente() + "\n" + " \tNome Cliente: " + nomeCliente + "\n" + "\n\tCdigo Pet: " + a.getIdAnimal() + "\n" + "\n\tNome: " + a.getNome() + "\n\tEspcie: " + a.getEspecie().trim(); if (a.getSexo().equals("F")) { sexoAnimal = "\n\tSexo: Feminino"; } else { sexoAnimal = "\n\tSexo: Masculino"; } resultado += sexoAnimal; resultado += " " + "\n\tRaa: " + a.getRaca().trim() + "\n\tAltura: " + a.getAltura().trim() + " cm \t- Peso: " + a.getPeso() + " kg" + "\n\tNascimento: " + a.getNascimento().trim(); resultado += newline; } resultado = "\n\n\t\t\t CADASTRO ANIMAIS / PETS\n" + resultado; txtRelPet.setText(resultado); txtRelPet.setEditable(false); //lblFotoPetRel.setVisible(true); colocarMiniFotoRelLabel(); } private void colocarMiniFotoRelLabel() { Animal animal = new Animal(); AnimalCtrl canimal = new AnimalCtrl(); nomeAnimal = cbxNomePet.getSelectedItem() + ""; animal = canimal.receberAnimalNome(nomeAnimal); urlMiniFoto = animal.getFoto(); Dimension d = lblFotoPetRel.getSize(); int width = lblFotoPetRel.getWidth(); int height = lblFotoPetRel.getHeight(); //System.out.println("width: "+d.width + " height: "+d.height); String urlFoto = urlMiniFoto; //pegar do combobox ImageIcon foto; foto = new ImageIcon(urlFoto); foto.setImage(foto.getImage().getScaledInstance(d.width, d.height, 100)); //img.setImage(img.getImage().getScaledInstance(xLargura, yAltura, 100)); lblFotoPetRel.setIcon(foto); //lblFotoPet.setIcon(new javax.swing.ImageIcon(getClass().getResource(urlFoto))); } private void colocarMiniFotoLabelVaga() { urlMiniFoto = ""; Dimension d = lblFotoPetRel.getSize(); int width = lblFotoPetRel.getWidth(); int height = lblFotoPetRel.getHeight(); //System.out.println("width: "+d.width + " height: "+d.height); String urlFoto = urlMiniFoto; //pegar do combobox ImageIcon foto; foto = new ImageIcon(urlFoto); foto.setImage(foto.getImage().getScaledInstance(d.width, d.height, 100)); //img.setImage(img.getImage().getScaledInstance(xLargura, yAltura, 100)); lblFotoPetRel.setIcon(foto); //lblFotoPet.setIcon(new javax.swing.ImageIcon(getClass().getResource(urlFoto))); } private void carregarListaAgendamentoCliente(List<Agendamento> ListaAgendamentos) { String newline = System.getProperty("line.separator"); //verificar propriedades de System.getProperty String resultado = ""; String nomeAnimal; String nomeCliente = ""; ClienteCtrl cliente = new ClienteCtrl(); AnimalCtrl canimal = new AnimalCtrl(); //for (Cliente c : ListaClientes) { // for (Animal a : ListaAnimais) { for (Agendamento ag : ListaAgendamentos) { nomeCliente = cliente.buscarNomeId(ag.getClienteId() + ""); Animal animal = canimal.receberAnimaId(ag.getAnimalId()); resultado += "" + "\nId Agendamento: " + ag.getIdAgendamento() + "\n" + "\nData: " + ag.getDataAgendamento() + " - " + "Horrio: " + ag.getHoraAgendamento() + "\n" + "\nCdigo Cliente: " + ag.getClienteId() + " - " + "\tNome Cliente: " + nomeCliente + "\n" + "Cdigo Pet: " + ag.getAnimalId() + " - " + "\tNome Pet: " + animal.getNome() + "\n" + "Cdigo Servio: " + ag.getIdServico() + " - " + "\tDescrio do Servio: " + ag.getServico() + "\n"; resultado += newline; } resultado = "\n\n\t\t\t AGENDAMENTO DE SERVIOS - CLIENTE\n" + resultado; txtRelPet.setText(resultado); txtRelPet.setEditable(false); //lblFotoPetRel.setVisible(true); colocarMiniFotoRelLabel(); } }//Final da Classe TelaRelatorioPet