How to do Jframe with JmenuBar calling another JFrame?

0

Hello, I have a main class that is working but at the time of clicking on the Registration menu and then client it does not call the other JFrame screen CustomerContentUI.

Here is the snippet that was to call the other JFrame that is implemented in another class ..

//criando o MenuItem cliente para executar o cadastro de clientes
    JMenuItem menuItemCadastro = new JMenuItem("Cadastro");
    menuItemCadastro.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e){
            new CadastroClienteUI();
        }
    });

Here is the class UserCountUI

public class CadastroClienteUI {

public CadastroClienteUI(){

    final JFrame frameCadastroCliente = new JFrame("Cadastro de Cliente");
    frameCadastroCliente.setSize(400,240);
    frameCadastroCliente.setVisible(true);
    frameCadastroCliente.setLocationRelativeTo(null);

    JPanel panel = new JPanel();

    JLabel rotuloNome = new JLabel();
    rotuloNome.setText("Nome: ");
    panel.add(rotuloNome);

    final JTextField textFieldNome = new JTextField(30);
    panel.add(textFieldNome);

    JLabel rotuloTelefone = new JLabel();
    rotuloTelefone.setText("Telefone: ");
    panel.add(rotuloTelefone);

    final JTextField textFieldTelefone = new JTextField(30);
    panel.add(textFieldTelefone);

    JLabel rotuloRG = new JLabel();
    rotuloRG.setText("RG: ");
    panel.add(rotuloRG);

    final JTextField textFieldRG = new JTextField(30);
    panel.add(textFieldRG);

    JLabel rotuloCPF = new JLabel();
    rotuloCPF.setText("CPF: ");
    panel.add(rotuloCPF);

    final JTextField textFieldCPF = new JTextField(30);
    panel.add(textFieldCPF);

    JLabel rotuloEndereco = new JLabel();
    rotuloEndereco.setText("Endereço: ");
    panel.add(rotuloEndereco);

    final JTextField textFieldEndereco = new JTextField(30);
    panel.add(textFieldEndereco);

    JButton buttonSalvar = new JButton ("Salvar");
    buttonSalvar.addActionListener(new ActionListener(){

        @Override
        public void actionPerformed(ActionEvent e){

            //InsereCliente insereCliente = new InsereCliente();
            JDBCClienteDAO insereCliente = new JDBCClienteDAO();

            Cliente cliente = new Cliente();
            cliente.setNome(textFieldNome.getText());
            cliente.setTelefone(textFieldTelefone.getText());
            cliente.setRG(textFieldRG.getText());
            cliente.setCPF(textFieldCPF.getText());
            cliente.setEndereco(textFieldEndereco.getText());

            insereCliente.gravaCliente(cliente);
        }
    });

    panel.add(buttonSalvar);

    JButton buttonCancelar = new JButton("Cancelar");
    buttonCancelar.addActionListener(new ActionListener(){

        @Override
        public void actionPerformed(ActionEvent e){
        frameCadastroCliente.dispose();
        }
    });

    panel.add(buttonCancelar);

    frameCadastroCliente.setContentPane(panel);
    frameCadastroCliente.setVisible(true);
}

}

    
asked by anonymous 02.03.2017 / 20:16

0 answers