[AJUDA] Sistema Gerenciador de Loja de CDs

Olá Pessoal,

Bem, estamos desenvolvimento como trabalho escolar um sistema gerenciador de loja de cds. Ele está sendo construido no NetBeans 6.5, e está sendo utilizado o banco de dados H2. Tal projeto pode ser obtido via Subversion no site a seguir:

http://code.google.com/p/sistema-gerenciador-loja-cds/source/checkout

O programa ainda está em desenvolvimento. Durante sua execução, no entanto, o Netbeans lança a seguinte mensagem de exceção ao tentar cadastrar um cliente:

run:
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
        at br.edu.ifrn.dominio.Cliente.<init>(Cliente.java:29)
        at br.edu.ifrn.gui.CadastroCliente.cadastrarActionPerformed(CadastroCliente.java:314)
        at br.edu.ifrn.gui.CadastroCliente.access$000(CadastroCliente.java:24)
        at br.edu.ifrn.gui.CadastroCliente$1.actionPerformed(CadastroCliente.java:133)
        at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
        at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318)
        at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
        at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
        at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
        at java.awt.Component.processMouseEvent(Component.java:6041)
        at javax.swing.JComponent.processMouseEvent(JComponent.java:3265)
        at java.awt.Component.processEvent(Component.java:5806)
        at java.awt.Container.processEvent(Container.java:2058)
        at java.awt.Component.dispatchEventImpl(Component.java:4413)
        at java.awt.Container.dispatchEventImpl(Container.java:2116)
        at java.awt.Component.dispatchEvent(Component.java:4243)
        at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4322)
        at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3986)
        at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3916)
        at java.awt.Container.dispatchEventImpl(Container.java:2102)
        at java.awt.Window.dispatchEventImpl(Window.java:2440)
        at java.awt.Component.dispatchEvent(Component.java:4243)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
        at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
        at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)

Ao tentar cadastrar um CD ou um cliente, um erro bastante semelhante a este também acontece, e não estamos sabendo como resolvê-lo. Acreditamos, no entanto, que tal problema esteja relacionado a várias referências geradas na tela de login do sistema. Alguém poderia o mais breve possível ajudar-nos, uma vez que este programa deverá ser entregue já na próxima semana?

Agradecemos desde já.

Posta sua classe de inserção no banco de dados!

De inicio de uma olhada nestas linhas

at br.edu.ifrn.dominio.Cliente.<init>(Cliente.java:29) at br.edu.ifrn.gui.CadastroCliente.cadastrarActionPerformed(CadastroCliente.java:314) at br.edu.ifrn.gui.CadastroCliente.access$000(CadastroCliente.java:24)

Você usa algum framework para persistir os dados ?

[quote=edmarr]De inicio de uma olhada nestas linhas

at br.edu.ifrn.dominio.Cliente.<init>(Cliente.java:29) at br.edu.ifrn.gui.CadastroCliente.cadastrarActionPerformed(CadastroCliente.java:314) at br.edu.ifrn.gui.CadastroCliente.access$000(CadastroCliente.java:24)[/quote]

Segue abaixo o codigo da classe de inserção do Cliente

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package br.edu.ifrn.dao;

import br.edu.ifrn.dominio.Cliente;
import br.edu.ifrn.dominio.Conta;
import br.edu.ifrn.dominio.Funcionario;
import java.sql.Connection;
import java.sql.Date;
import java.sql.PreparedStatement ;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.LinkedList;
import javax.swing.JOptionPane;

/**
 *
 * @author Denis
 */
public class ClienteDAO {

    Connection conexao;

    public ClienteDAO(){
        conexao = ConnectionFactory.getConnection();
    }

    public void addCliente(Cliente c){
        try{
            
            String ins = "INSERT INTO cliente VALUES(?,?,?,?,?,?,?,?,?);";
            PreparedStatement stm = conexao.prepareStatement(ins);

            java.util.Date data = c.getDataNasc();
            java.sql.Date datasql = new java.sql.Date(data.getTime());
            
            stm.setString(1, c.getCpf());
            stm.setInt(2, c.getConta().getCodigo());
            stm.setString(3, c.getFunc());
            stm.setString(4, c.getRg());
            stm.setString(5, c.getNome());
            stm.setString(6, c.getSexo());
            stm.setString(7, c.getTelefone());
            stm.setString(8, c.getEstCivil());
            stm.setDate(9, datasql);

            stm.executeUpdate();
            stm.close();
            conexao.close();

        }catch(SQLException ex){
            JOptionPane.showMessageDialog(null, "Não foi possível conectar ao banco de dados. \n" + ex.getMessage());
        }
    }

    public void updateCliente(Cliente c){
        try {
            
            String ins = "UPDATE cliente SET cpf='?', conta_codigo=?, funcionario_login='?', rg='?', nome='?', sexo='?', telefone='?', estado_civil='?', dnascimento=? WHERE cpf='?';";
            PreparedStatement stm = conexao.prepareStatement(ins);

            stm.setString(1, c.getCpf());
            stm.setInt(2, c.getConta().getCodigo());
            stm.setString(3, c.getFunc());
            stm.setString(4, c.getRg());
            stm.setString(5, c.getNome());
            stm.setString(6, c.getSexo());
            stm.setString(7, c.getTelefone());
            stm.setString(8, c.getEstCivil());
            stm.setDate(9,(Date) c.getDataNasc());
            stm.setString(10, c.getCpf());

            stm.executeUpdate();
            stm.close();
            conexao.close();

        } catch(SQLException ex){
           JOptionPane.showMessageDialog(null, "Não foi possível conectar ao banco de dados. \n" + ex.getMessage());
        }
    }

    public void deleteCliente(Cliente c){
        try {
            
            String ins = "DELETE FROM cliente WHERE cpf='?';";
            PreparedStatement stm = conexao.prepareStatement(ins);

            stm.setString(1, c.getCpf());

            stm.executeUpdate();
            stm.close();
            conexao.close();

        } catch(SQLException ex){
            JOptionPane.showMessageDialog(null, "Não foi possível conectar ao banco de dados. \n" + ex.getMessage());
        }
    }

    public LinkedList<Cliente> selectCliente(){
        LinkedList<Cliente> listaCli = new LinkedList();
        try {
           
            String ins = "SELECT * FROM cliente;";
            PreparedStatement stm = conexao.prepareStatement(ins);

            ResultSet rs = (ResultSet) stm.executeQuery();

            FuncionarioDAO fdao = new FuncionarioDAO();
            LinkedList<Funcionario> listaFunc = fdao.selectFuncionario();

            ContaDAO cdao = new ContaDAO();
            LinkedList<Conta> listaConta = cdao.selectConta();         
                      
            Conta conta = null;

            while(rs.next()){
                for(Conta cont: listaConta){
                    if(cont.getCodigo() == rs.getInt(2)){
                        conta = cont;
                        break; // sai do loop
                    }
                }

                for(Funcionario f: listaFunc){
                    if(f.getCpf().equals(rs.getString(3))){
                        Cliente c = new Cliente(rs.getString(1), f, rs.getString(4), rs.getString(5), rs.getString(6), rs.getString(7), rs.getString(8), rs.getDate(9), conta);
                        listaCli.add(c);
                        break;
                    }
                }
            }

            rs.close();
            stm.close();
            conexao.close();

        } catch(SQLException ex){
             JOptionPane.showMessageDialog(null, "Não foi possível conectar ao banco de dados. \n" + ex.getMessage());
        }

        return listaCli;
    }

}

O erro sempre é referente à classe Cliente, especificamente à linha func.getLogin(). Segue o codigo da classe abaixo:

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package br.edu.ifrn.dominio;

import java.util.Date;

/**
 *
 * @author 2007134010475
 */
public class Cliente {
    private String cpf;
    private Funcionario func;
    private String rg;
    private String nome;
    private String sexo;
    private String telefone;
    private String estCivil;
    private Date dataNasc;
    private Conta conta;
   
    

    public Cliente(String cpf, Funcionario func, String rg, String nome, String sexo, String telefone, String estCivil, Date dataNasc, Conta conta) {
        this.cpf = cpf;
        this.func = func;
        this.rg = rg;
        this.nome = nome;
        this.sexo = sexo;
        this.telefone = telefone;
        this.estCivil = estCivil;
        this.dataNasc = dataNasc;
        this.conta = conta;
    }

    public Conta getConta() {
        return conta;
    }

    public void setConta(Conta conta) {
        this.conta = conta;
    }

    public String getCpf() {
        return cpf;
    }

    public void setCpf(String cpf) {
        this.cpf = cpf;
    }

    public Date getDataNasc() {
        return dataNasc;
    }

    public void setDataNasc(Date dataNasc) {
        this.dataNasc = dataNasc;
    }

    public String getEstCivil() {
        return estCivil;
    }

    public void setEstCivil(String estCivil) {
        this.estCivil = estCivil;
    }

    public String getFunc() {
        return func.getLogin();
    }

    public void setFunc(Funcionario func) {
        this.func = func;
    }

    public String getNome() {
        return nome;
    }

    public void setNome(String nome) {
        this.nome = nome;
    }

    public String getRg() {
        return rg;
    }

    public void setRg(String rg) {
        this.rg = rg;
    }

    public String getSexo() {
        return sexo;
    }

    public void setSexo(String sexo) {
        this.sexo = sexo;
    }

    public String getTelefone() {
        return telefone;
    }

    public void setTelefone(String telefone) {
        this.telefone = telefone;
    }

    



    

}

Não, não estamos utilizando.

a tua sql de inserção esta errada se nao me engano!

public void addCliente(Cliente c){
   try{
      String ins = "INSERT INTO cliente VALUES(?,?,?,?,?,?,?,?,?);";
      PreparedStatement stm = conexao.prepareStatement(ins);

      java.util.Date data = c.getDataNasc();
      java.sql.Date datasql = new java.sql.Date(data.getTime());
            
      stm.setString(1, c.getCpf());
      stm.setInt(2, c.getConta().getCodigo());
      stm.setString(3, c.getFunc());
      stm.setString(4, c.getRg());
      stm.setString(5, c.getNome());
      stm.setString(6, c.getSexo());
      stm.setString(7, c.getTelefone());
      stm.setString(8, c.getEstCivil());
      stm.setDate(9, datasql);

      stm.executeUpdate();
      stm.close();
      conexao.close();

   }catch(SQLException ex){
      JOptionPane.showMessageDialog(null, "Não foi possível conectar ao banco de dados. \n" + ex.getMessage());
   }
}

tente assim:

[code]public void addCliente(Cliente c){
try{
String ins = “INSERT INTO cliente (cpf, codigo, func, rg, nome, sexo, telefone, estcivil, datasql)VALUES(?,?,?,?,?,?,?,?,?);”; //Nomes das tuas colunas ali!
PreparedStatement stm = conexao.prepareStatement(ins);

  java.util.Date data = c.getDataNasc();
  java.sql.Date datasql = new java.sql.Date(data.getTime());
        
  stm.setString(1, c.getCpf());
  stm.setInt(2, c.getConta().getCodigo());
  stm.setString(3, c.getFunc());
  stm.setString(4, c.getRg());
  stm.setString(5, c.getNome());
  stm.setString(6, c.getSexo());
  stm.setString(7, c.getTelefone());
  stm.setString(8, c.getEstCivil());
  stm.setDate(9, datasql);

  stm.executeUpdate();
  stm.close();
  conexao.close();

}catch(SQLException ex){
JOptionPane.showMessageDialog(null, “Não foi possível conectar ao banco de dados. \n” + ex.getMessage());
}
}[/code]

Se você for fazer insert em todos os campos da tabela não precisa indicar os campos, basta colocar o VALUES msm…

A minha dúvida é, está dando NullPointerException, todos os parametros passados para o Cliente foram criados, digo, foi dado um new ou atribuido a algum objeto já existente ?

[quote=ivandasilva]Se você for fazer insert em todos os campos da tabela não precisa indicar os campos, basta colocar o VALUES msm…

A minha dúvida é, está dando NullPointerException, todos os parametros passados para o Cliente foram criados, digo, foi dado um new ou atribuido a algum objeto já existente ?[/quote]

Foi atribuido a algum objeto já existente. É interessante que baixem o codigo do projeto, uma vez que dessa forma a compreensão do problema torna-se melhor.

Aí fica complicado… :stuck_out_tongue:

Acho que boa parte olha o forum entre um deploy e outro…

Boa tarde.

É como o nosso colego disse, a maioria do pessoal acessa entre um build e outro.
Mas devo dizer duas coisas:

1- Retire o ; ao fim dos seus comandos SQL entre asplas duplas ok? Exemplo: “Select id from cliente;”; É sem o ; assim: “Select id from cliente”; ok?

2 - NullPointerException, ou seja, em algum momento do seu código você está acessando um valor através de um objeto nulo ok? Fique atento a isto.

Então, encerrando, como já disseram a você, veja estas linhas:

at br.edu.ifrn.dominio.Cliente.<init>(Cliente.java:29) at br.edu.ifrn.gui.CadastroCliente.cadastrarActionPerformed(CadastroCliente.java:314) at br.edu.ifrn.gui.CadastroCliente.access$000(CadastroCliente.java:24)

E se “olhando” não conseguir identificar em qual momento pode ocorrer o NullPointer debug seu código.
Abraços :slight_smile:

Você disse que o problema está nesta linha?

public String getFunc() { return func.getLogin(); }

99% de certeza que o seu objeto func está nulo :slight_smile:

Olá, pessoal!

Também sou membro do grupo do criador do tópico. Ainda não conseguimos resolver o problema. Vou tentar explicar melhor o nosso problema:

O problema ocorre na seguinte situação: na tela de login (TelaLogin) do nosso sistema é criado uma LinkedList, do tipo Funcionario, com todos os funcionarios cadastrados no banco de dados. Através de um loop for, procuramos o objeto na lista que tenha dos dados de login. Caso encontre tal funcionario, o programa abrirá a tela principal. Sendo que nessa nova tela, chamada de TelaPrincipalAdministrador (ou a do funcionario), precisamos do objeto daquela LinkedList referente ao funcionario logado. Sendo que a JVM diz que o objeto está nullo e acaba gerando tal erro. Aí nós estamos achando que o problema está relacionado a passagem desse objeto para a janela (JFrame seguinte). Já pesquisamos e tentamos de tudo mas não conseguimos resolver o problema. O problema maior é que temos que entregar até a próxima semana. Ficaríamos muito gratos caso alguém nos ajudasse.

Segue abaixo as classes que me referi:

[code]/*

  • To change this template, choose Tools | Templates
  • and open the template in the editor.
    */

/*

  • TelaLogin.java
  • Created on 12/11/2009, 13:19:35
    */

package br.edu.ifrn.gui;

import br.edu.ifrn.dao.FuncionarioDAO;
import br.edu.ifrn.dominio.Funcionario;
import java.awt.Image;
import java.util.LinkedList;
import javax.swing.JOptionPane;

/**
*

  • @author 2007134010467
    */
    public class TelaLogin extends javax.swing.JFrame {

    /** Creates new form TelaLogin */
    public TelaLogin() {
    initComponents();
    }

    private Image icone() {
    return new javax.swing.ImageIcon(getClass().getResource("/br/edu/ifrn/imagens/icone.png")).getImage();
    }

    /** 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”)
      //
      private void initComponents() {

      jLabel1 = new javax.swing.JLabel();
      separador = new javax.swing.JSeparator();
      jLabel2 = new javax.swing.JLabel();
      login = new javax.swing.JTextField();
      jLabel3 = new javax.swing.JLabel();
      senha = new javax.swing.JPasswordField();
      efeturarLogin = new javax.swing.JButton();
      limpar = new javax.swing.JButton();
      cancelar = new javax.swing.JButton();

      setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
      setTitle(“Sistema Gereciador de Loja de CDs”);
      setResizable(false);

      jLabel1.setFont(new java.awt.Font(“Tahoma”, 1, 12));
      jLabel1.setText(“Faça o login preenchendo todos os campos abaixo:”);

      jLabel2.setFont(new java.awt.Font(“Tahoma”, 0, 12));
      jLabel2.setText(“Login:”);

      login.setFont(new java.awt.Font(“Tahoma”, 0, 12)); // NOI18N

      jLabel3.setFont(new java.awt.Font(“Tahoma”, 0, 12));
      jLabel3.setText(“Senha:”);

      efeturarLogin.setFont(new java.awt.Font(“Tahoma”, 0, 12)); // NOI18N
      efeturarLogin.setForeground(new java.awt.Color(0, 102, 0));
      efeturarLogin.setText(“Efetuar Login”);
      efeturarLogin.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
      efeturarLoginActionPerformed(evt);
      }
      });

      limpar.setFont(new java.awt.Font(“Tahoma”, 0, 12)); // NOI18N
      limpar.setText(“Limpar”);
      limpar.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
      limparActionPerformed(evt);
      }
      });

      cancelar.setFont(new java.awt.Font(“Tahoma”, 0, 12));
      cancelar.setForeground(new java.awt.Color(255, 0, 0));
      cancelar.setText(“Cancelar”);
      cancelar.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
      cancelarActionPerformed(evt);
      }
      });

      javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
      getContentPane().setLayout(layout);
      layout.setHorizontalGroup(
      layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
      .addContainerGap()
      .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
      .addGroup(layout.createSequentialGroup()
      .addComponent(efeturarLogin)
      .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
      .addComponent(limpar)
      .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
      .addComponent(cancelar))
      .addComponent(jLabel1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
      .addComponent(separador, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 312, Short.MAX_VALUE)
      .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
      .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
      .addComponent(jLabel2)
      .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
      .addComponent(login, javax.swing.GroupLayout.DEFAULT_SIZE, 269, Short.MAX_VALUE))
      .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
      .addComponent(jLabel3)
      .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
      .addComponent(senha))))
      .addContainerGap())
      );
      layout.setVerticalGroup(
      layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(layout.createSequentialGroup()
      .addContainerGap()
      .addComponent(jLabel1)
      .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
      .addComponent(separador, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
      .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
      .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
      .addComponent(jLabel2)
      .addComponent(login, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
      .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
      .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
      .addComponent(jLabel3)
      .addComponent(senha, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
      .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 18, Short.MAX_VALUE)
      .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
      .addComponent(cancelar)
      .addComponent(limpar)
      .addComponent(efeturarLogin))
      .addContainerGap())
      );

      pack();
      }//

    private void efeturarLoginActionPerformed(java.awt.event.ActionEvent evt) {
    boolean aux = false; // variavel auxiliar p/ verificar se o login e a senha não correspondem a nenhum funcionario
    LinkedList list;
    FuncionarioDAO funcdao = new FuncionarioDAO();

     list = funcdao.selectFuncionario();
     String log = login.getText();
     String sen = senha.getText();
    
    for(Funcionario f: list){
        if ((f.getLogin().equals(log))&&(f.getSenha().equals(sen))){
            if(f.isIsAdm()){
                 TelaPrincipalAdministrador tpa = new TelaPrincipalAdministrador(f);
                 this.setVisible(false);
                 tpa.setVisible(true);
                 this.dispose();
                 break;
            }
            else{
                 TelaPrincipalFuncionario tpf = new TelaPrincipalFuncionario(f);
                 tpf.setVisible(true);
                 this.setVisible(false);
                 this.dispose();
                 break;
            }
        }
    
        else {
            aux = true;
        }
     }
    
    if(aux){ // Se o login e a senha digitados não correspondem a algum funcionário
       JOptionPane.showMessageDialog(null,"O login ou a senha estão incorretos. Tente novamente");
    }
    

    }

    private void limparActionPerformed(java.awt.event.ActionEvent evt) {
    senha.setText("");
    login.setText("");
    }

    private void cancelarActionPerformed(java.awt.event.ActionEvent evt) {
    System.exit(0);
    }

    /**

    • @param args the command line arguments
      */

    // Variables declaration - do not modify
    private javax.swing.JButton cancelar;
    private javax.swing.JButton efeturarLogin;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JButton limpar;
    private javax.swing.JTextField login;
    private javax.swing.JPasswordField senha;
    private javax.swing.JSeparator separador;
    // End of variables declaration

}
[/code]

[code]/*

  • To change this template, choose Tools | Templates
  • and open the template in the editor.
    */

/*

  • TelaPrincipalAdministrador.java
  • Created on 12/11/2009, 14:47:55
    */

package br.edu.ifrn.gui;

import br.edu.ifrn.dominio.Funcionario;
import java.awt.Image;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;

/**
*

  • @author 2007134010475
    */
    public class TelaPrincipalAdministrador extends javax.swing.JFrame {

    /** Creates new form TelaPrincipalAdministrador */
    public TelaPrincipalAdministrador(Funcionario f) {
    func = f;
    initComponents();
    iniciaRelogio();//inicia o relógio
    }

    Funcionario func;

    // Código para alterar o ícone da janela

    private Image icone() {
         return new javax.swing.ImageIcon(getClass().getResource("/br/edu/ifrn/imagens/icone.png")).getImage();
    }
    

    // Fim do código para alterar o ícone da janela

    /** 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”)
      //
      private void initComponents() {

      jLabel1 = new javax.swing.JLabel();
      logotipo = new javax.swing.JLabel();
      menurapido = new javax.swing.JPanel();
      realizarvenda = new javax.swing.JButton();
      pesquisarcd = new javax.swing.JButton();
      pesquisacliente = new javax.swing.JButton();
      cadastrarcd = new javax.swing.JButton();
      cadastrarcliente = new javax.swing.JButton();
      sac = new javax.swing.JButton();
      dataehora = new javax.swing.JPanel();
      dataHora = new javax.swing.JLabel();
      relogio = new javax.swing.JLabel();
      jLabel3 = new javax.swing.JLabel();
      menu = new javax.swing.JMenuBar();
      menuUsuario = new javax.swing.JMenu();
      opcaoTrocar = new javax.swing.JMenuItem();
      opcaoFinalizar = new javax.swing.JMenuItem();
      menuCadastrar = new javax.swing.JMenu();
      opcaoCliente = new javax.swing.JMenuItem();
      opcaoFuncionario = new javax.swing.JMenu();
      subOpcaoAdmin = new javax.swing.JMenuItem();
      subOpcaoVend = new javax.swing.JMenuItem();
      opcaoCD = new javax.swing.JMenuItem();
      gerenciar = new javax.swing.JMenu();
      gerenciarCD = new javax.swing.JMenuItem();
      gerenciarFunc = new javax.swing.JMenuItem();
      gerenciarCliente = new javax.swing.JMenuItem();
      menuVenda = new javax.swing.JMenu();
      opcaoRealizar = new javax.swing.JMenuItem();
      opcaoConsultar = new javax.swing.JMenuItem();
      menuSAC = new javax.swing.JMenu();
      opcaoLer = new javax.swing.JMenuItem();
      menuRelatorio = new javax.swing.JMenu();
      opcaoRelatorio = new javax.swing.JMenuItem();
      opcaoLerRel = new javax.swing.JMenuItem();
      menuAjuda = new javax.swing.JMenu();
      opcaoSobre = new javax.swing.JMenuItem();

      setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
      setTitle(“Gerenciador de Loja de CDs”);
      setIconImage(icone());
      setResizable(false);

      jLabel1.setText(“jLabel1”);

      menurapido.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED), “Menu Rápido”, javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font(“Tahoma”, 1, 12))); // NOI18N

      realizarvenda.setFont(new java.awt.Font(“Tahoma”, 1, 12));
      realizarvenda.setText(“Realizar Venda”);
      realizarvenda.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
      realizarvendaActionPerformed(evt);
      }
      });

      pesquisarcd.setFont(new java.awt.Font(“Tahoma”, 1, 12));
      pesquisarcd.setText(“Pesquisar CD”);
      pesquisarcd.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
      pesquisarcdActionPerformed(evt);
      }
      });

      pesquisacliente.setFont(new java.awt.Font(“Tahoma”, 1, 12));
      pesquisacliente.setText(“Pesquisar Cliente”);
      pesquisacliente.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
      pesquisaclienteActionPerformed(evt);
      }
      });

      cadastrarcd.setFont(new java.awt.Font(“Tahoma”, 1, 12));
      cadastrarcd.setText(“Cadastrar CD”);
      cadastrarcd.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
      cadastrarcdActionPerformed(evt);
      }
      });

      cadastrarcliente.setFont(new java.awt.Font(“Tahoma”, 1, 12));
      cadastrarcliente.setText(“Cadastrar Cliente”);
      cadastrarcliente.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
      cadastrarclienteActionPerformed(evt);
      }
      });

      sac.setFont(new java.awt.Font(“Tahoma”, 1, 12));
      sac.setText(“SAC”);
      sac.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
      sacActionPerformed(evt);
      }
      });

      javax.swing.GroupLayout menurapidoLayout = new javax.swing.GroupLayout(menurapido);
      menurapido.setLayout(menurapidoLayout);
      menurapidoLayout.setHorizontalGroup(
      menurapidoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(menurapidoLayout.createSequentialGroup()
      .addContainerGap()
      .addGroup(menurapidoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addComponent(realizarvenda, javax.swing.GroupLayout.DEFAULT_SIZE, 140, Short.MAX_VALUE)
      .addComponent(pesquisarcd, javax.swing.GroupLayout.DEFAULT_SIZE, 140, Short.MAX_VALUE)
      .addComponent(pesquisacliente, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 140, Short.MAX_VALUE)
      .addComponent(cadastrarcd, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 140, Short.MAX_VALUE)
      .addComponent(cadastrarcliente, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 140, Short.MAX_VALUE)
      .addComponent(sac, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 140, Short.MAX_VALUE))
      .addContainerGap())
      );
      menurapidoLayout.setVerticalGroup(
      menurapidoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(menurapidoLayout.createSequentialGroup()
      .addContainerGap()
      .addComponent(realizarvenda, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
      .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
      .addComponent(pesquisarcd, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
      .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
      .addComponent(pesquisacliente, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
      .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
      .addComponent(cadastrarcd, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
      .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
      .addComponent(cadastrarcliente, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
      .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
      .addComponent(sac, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
      .addContainerGap(18, Short.MAX_VALUE))
      );

      dataehora.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));

      dataHora.setFont(new java.awt.Font(“Tahoma”, 1, 18));
      dataHora.setForeground(java.awt.Color.blue);
      /*
      dataHora.setText(“00/00/0000”);
      */
      dataHora.setText(formatter.format(data));

      relogio.setFont(new java.awt.Font(“Tahoma”, 1, 18));
      relogio.setForeground(java.awt.Color.blue);
      relogio.setText(“00:00:00”);

      javax.swing.GroupLayout dataehoraLayout = new javax.swing.GroupLayout(dataehora);
      dataehora.setLayout(dataehoraLayout);
      dataehoraLayout.setHorizontalGroup(
      dataehoraLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(dataehoraLayout.createSequentialGroup()
      .addGap(89, 89, 89)
      .addComponent(dataHora)
      .addGap(16, 16, 16)
      .addComponent(relogio)
      .addContainerGap(89, Short.MAX_VALUE))
      );
      dataehoraLayout.setVerticalGroup(
      dataehoraLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(dataehoraLayout.createSequentialGroup()
      .addContainerGap()
      .addGroup(dataehoraLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addComponent(dataHora)
      .addComponent(relogio))
      .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
      );

      jLabel3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/br/edu/ifrn/imagens/telainicial.jpg"))); // NOI18N

      menuUsuario.setText(“Usuário”);
      menuUsuario.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
      menuUsuarioActionPerformed(evt);
      }
      });

      opcaoTrocar.setText(“Trocar”);
      opcaoTrocar.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
      opcaoTrocarActionPerformed(evt);
      }
      });
      menuUsuario.add(opcaoTrocar);

      opcaoFinalizar.setText(“Finalizar programa”);
      opcaoFinalizar.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
      opcaoFinalizarActionPerformed(evt);
      }
      });
      menuUsuario.add(opcaoFinalizar);

      menu.add(menuUsuario);

      menuCadastrar.setText(“Cadastro”);

      opcaoCliente.setText(“Cliente”);
      opcaoCliente.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
      opcaoClienteActionPerformed(evt);
      }
      });
      menuCadastrar.add(opcaoCliente);

      opcaoFuncionario.setText(“Funcionário”);

      subOpcaoAdmin.setText(“Administrador”);
      subOpcaoAdmin.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
      subOpcaoAdminActionPerformed(evt);
      }
      });
      opcaoFuncionario.add(subOpcaoAdmin);

      subOpcaoVend.setText(“Vendedor”);
      subOpcaoVend.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
      subOpcaoVendActionPerformed(evt);
      }
      });
      opcaoFuncionario.add(subOpcaoVend);

      menuCadastrar.add(opcaoFuncionario);

      opcaoCD.setText(“CD”);
      opcaoCD.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
      opcaoCDActionPerformed(evt);
      }
      });
      menuCadastrar.add(opcaoCD);

      menu.add(menuCadastrar);

      gerenciar.setText(“Gerenciar”);

      gerenciarCD.setText(“CD”);
      gerenciarCD.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
      gerenciarCDActionPerformed(evt);
      }
      });
      gerenciar.add(gerenciarCD);

      gerenciarFunc.setText(“Funcionário”);
      gerenciarFunc.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
      gerenciarFuncActionPerformed(evt);
      }
      });
      gerenciar.add(gerenciarFunc);

      gerenciarCliente.setText(“Cliente”);
      gerenciarCliente.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
      gerenciarClienteActionPerformed(evt);
      }
      });
      gerenciar.add(gerenciarCliente);

      menu.add(gerenciar);

      menuVenda.setText(“Venda”);

      opcaoRealizar.setText(“Realizar”);
      opcaoRealizar.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
      opcaoRealizarActionPerformed(evt);
      }
      });
      menuVenda.add(opcaoRealizar);

      opcaoConsultar.setText(“Consultar”);
      opcaoConsultar.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
      opcaoConsultarActionPerformed(evt);
      }
      });
      menuVenda.add(opcaoConsultar);

      menu.add(menuVenda);

      menuSAC.setText(“SAC”);

      opcaoLer.setText(“Ler mensagens”);
      opcaoLer.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
      opcaoLerActionPerformed(evt);
      }
      });
      menuSAC.add(opcaoLer);

      menu.add(menuSAC);

      menuRelatorio.setText(“Relatório”);

      opcaoRelatorio.setText(“Gerar”);
      opcaoRelatorio.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
      opcaoRelatorioActionPerformed(evt);
      }
      });
      menuRelatorio.add(opcaoRelatorio);

      opcaoLerRel.setText(“Ler anteriores”);
      opcaoLerRel.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
      opcaoLerRelActionPerformed(evt);
      }
      });
      menuRelatorio.add(opcaoLerRel);

      menu.add(menuRelatorio);

      menuAjuda.setText(“Ajuda”);

      opcaoSobre.setText(“Sobre”);
      opcaoSobre.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
      opcaoSobreActionPerformed(evt);
      }
      });
      menuAjuda.add(opcaoSobre);

      menu.add(menuAjuda);

      setJMenuBar(menu);

      javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
      getContentPane().setLayout(layout);
      layout.setHorizontalGroup(
      layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(layout.createSequentialGroup()
      .addContainerGap()
      .addComponent(menurapido, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
      .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(layout.createSequentialGroup()
      .addGap(126, 126, 126)
      .addComponent(logotipo))
      .addGroup(layout.createSequentialGroup()
      .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
      .addComponent(dataehora, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
      .addGroup(layout.createSequentialGroup()
      .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
      .addComponent(jLabel3)))
      .addContainerGap())
      );
      layout.setVerticalGroup(
      layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(layout.createSequentialGroup()
      .addContainerGap()
      .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(layout.createSequentialGroup()
      .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 241, javax.swing.GroupLayout.PREFERRED_SIZE)
      .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
      .addComponent(logotipo)
      .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 8, Short.MAX_VALUE)
      .addComponent(dataehora, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
      .addComponent(menurapido, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
      .addContainerGap())
      );

      pack();
      }//

    Venda v = new Venda();
    private void realizarvendaActionPerformed(java.awt.event.ActionEvent evt) {
    v.setVisible(true);
    }

    PesquisaCD pcd = new PesquisaCD();
    private void pesquisarcdActionPerformed(java.awt.event.ActionEvent evt) {
    pcd.setVisible(true);
    }

    PesquisaCliente pcli = new PesquisaCliente();
    private void pesquisaclienteActionPerformed(java.awt.event.ActionEvent evt) {
    pcli.setVisible(true);
    }

    CadastroCD cadcd = new CadastroCD(func);
    private void cadastrarcdActionPerformed(java.awt.event.ActionEvent evt) {
    cadcd.setVisible(true);
    }

    CadastroCliente cadcli = new CadastroCliente(func);
    private void cadastrarclienteActionPerformed(java.awt.event.ActionEvent evt) {
    cadcli.setVisible(true);
    }

    SACListaMensagens saclist = new SACListaMensagens();
    private void sacActionPerformed(java.awt.event.ActionEvent evt) {
    saclist.setVisible(true);
    }

    TelaLogin tl = new TelaLogin();
    private void opcaoTrocarActionPerformed(java.awt.event.ActionEvent evt) {
    this.setDefaultCloseOperation(1);
    tl.setVisible(true);
    }

    private void opcaoFinalizarActionPerformed(java.awt.event.ActionEvent evt) {
    System.exit(0);
    }

    private void opcaoClienteActionPerformed(java.awt.event.ActionEvent evt) {
    cadcli.setVisible(true);
    }

    private void opcaoCDActionPerformed(java.awt.event.ActionEvent evt) {
    cadcd.setVisible(true);
    }

    CadastroAdministrador cadm = new CadastroAdministrador();
    private void subOpcaoAdminActionPerformed(java.awt.event.ActionEvent evt) {
    cadm.setVisible(true);
    }

    CadastroVendedor cvend = new CadastroVendedor(func);
    private void subOpcaoVendActionPerformed(java.awt.event.ActionEvent evt) {
    cvend.setVisible(true);
    }

    private void opcaoRealizarActionPerformed(java.awt.event.ActionEvent evt) {
    v.setVisible(true);
    }

    ListaVendas lv = new ListaVendas();
    private void opcaoConsultarActionPerformed(java.awt.event.ActionEvent evt) {
    lv.setVisible(true);
    }

    private void opcaoLerActionPerformed(java.awt.event.ActionEvent evt) {
    saclist.setVisible(true);
    }

    Relatorio r = new Relatorio();
    private void opcaoRelatorioActionPerformed(java.awt.event.ActionEvent evt) {
    r.setVisible(true);
    }

    DataRelatorio dp = new DataRelatorio();
    private void opcaoLerRelActionPerformed(java.awt.event.ActionEvent evt) {
    dp.setVisible(true);
    }

    Sobre s = new Sobre();
    private void opcaoSobreActionPerformed(java.awt.event.ActionEvent evt) {
    s.setVisible(true);
    }

    private void menuUsuarioActionPerformed(java.awt.event.ActionEvent evt) {
    // TODO add your handling code here:
    }
    GerenciarCD g = new GerenciarCD();
    private void gerenciarCDActionPerformed(java.awt.event.ActionEvent evt) {
    g.setVisible(true);
    }
    GerenciarFuncionario g2 = new GerenciarFuncionario();
    private void gerenciarFuncActionPerformed(java.awt.event.ActionEvent evt) {
    g2.setVisible(true);
    }
    GerenciarCliente g3 = new GerenciarCliente();
    private void gerenciarClienteActionPerformed(java.awt.event.ActionEvent evt) {
    g3.setVisible(true);
    }

    /**

    • @param args the command line arguments
      */

    private Date data = new Date();
    String formato = “dd/MM/yyyy”;
    SimpleDateFormat formatter = new SimpleDateFormat(formato);

    // Variables declaration - do not modify
    private javax.swing.JButton cadastrarcd;
    private javax.swing.JButton cadastrarcliente;
    private javax.swing.JLabel dataHora;
    private javax.swing.JPanel dataehora;
    private javax.swing.JMenu gerenciar;
    private javax.swing.JMenuItem gerenciarCD;
    private javax.swing.JMenuItem gerenciarCliente;
    private javax.swing.JMenuItem gerenciarFunc;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel logotipo;
    private javax.swing.JMenuBar menu;
    private javax.swing.JMenu menuAjuda;
    private javax.swing.JMenu menuCadastrar;
    private javax.swing.JMenu menuRelatorio;
    private javax.swing.JMenu menuSAC;
    private javax.swing.JMenu menuUsuario;
    private javax.swing.JMenu menuVenda;
    private javax.swing.JPanel menurapido;
    private javax.swing.JMenuItem opcaoCD;
    private javax.swing.JMenuItem opcaoCliente;
    private javax.swing.JMenuItem opcaoConsultar;
    private javax.swing.JMenuItem opcaoFinalizar;
    private javax.swing.JMenu opcaoFuncionario;
    private javax.swing.JMenuItem opcaoLer;
    private javax.swing.JMenuItem opcaoLerRel;
    private javax.swing.JMenuItem opcaoRealizar;
    private javax.swing.JMenuItem opcaoRelatorio;
    private javax.swing.JMenuItem opcaoSobre;
    private javax.swing.JMenuItem opcaoTrocar;
    private javax.swing.JButton pesquisacliente;
    private javax.swing.JButton pesquisarcd;
    private javax.swing.JButton realizarvenda;
    private javax.swing.JLabel relogio;
    private javax.swing.JButton sac;
    private javax.swing.JMenuItem subOpcaoAdmin;
    private javax.swing.JMenuItem subOpcaoVend;
    // End of variables declaration

    // label onde será impressa a hora atual

    // Thread responsável pelo relório

    public void iniciaRelogio(){
    new Thread(){//instancia nova thread já implementando o método run()
    @Override
    public void run() {//sobrescreve o método run()

     		while(true){//while para fazer o loop infinito
     			GregorianCalendar gc = new GregorianCalendar();//novo gregorian calendar, onde temos a data atual
     			int hora = gc.get(Calendar.HOUR_OF_DAY);//pega as horas
     			int minuto = gc.get(Calendar.MINUTE);//pega os minutos
     			int segundo = gc.get(Calendar.SECOND);//pega os segundos
     			String horaString;//nova string horas
     			String minString;//nova string minutos
     			String segundoString;//nova string segundos
     			if(hora < 10){//se hora for menor que 10 precisa colocar um 0 à esquerda
     				horaString = "0"+hora;
     			}else{
     				horaString = ""+hora;
     			}
     			if(minuto < 10){//se minuto for menor que 10 precisa colocar um 0 à esquerda
     				minString = "0"+minuto;
     			}else{
     				minString = ""+minuto;
     			}
     			if(segundo < 10){//se segundo for menor que 10 precisa colocar um 0 à esquerda
     				segundoString = "0"+segundo;
     			}else{
     				segundoString = ""+segundo;
     			}
     			relogio.setText(horaString+":"+minString+":"+segundoString);//seta hora atual no label
     			try{
     				sleep(1000);//faz a thread entrar em estado de espera por 1000 milissegundos ou 1 segundo
     			}catch(Exception e){}
     		}
     	}
     }.start();//inicia a thread.
    

    }

}

[/code]

Agradecemos desde já!

UP!

Boa noite nascinho, tudo beleza?

Pelo que vejo, você está tentando chamar um método de uma classe que não foi instanciada.

Na sua classe Cliente, para testar, tente alterar o método getFunc() para:

public String getFunc() { func = new Funcionario(); return func.getLogin(); }

A não ser que o método getLogin() da classe Funcionario seja estático! Caso seja, esqueça o que leu até aqui, hehe!

Até mais.

Na classe CadastroCliente, na linha 314, você cria um novo Cliente, passando para ele o parâmetro ‘func’. Acontece que esse parêmetro foi recebido via construtor. E isso remete que, em algum momento, ele é resgatado do banco. Há algum problema com a persistência de dados, eu acho.