Ajuda com metedos get e set

2 respostas
cleyvison

Pessoal boa noite, pesquisei aqui no forum e via alguns tópicos relacio an do a este assunto mas, não compreendi bem…

por isso abri este novo…

meu problema é o seguinte…

to fazendo um trabalho par aa faculdade… o programa deve cadastrar clientes, cadastrar remesas, cadastrar boletos,
a interface (meia boca) eu ja fiz…
armazenar as variavel tb ja consegui mas, eu devo fazer isso usando get e set.

abaixo posto meu codigo…

package SisGenEnc;

import java.awt.Color;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;

public class SisGenEnc extends JFrame implements ActionListener 
{
	private static final long serialVersionUID = 1L;

	static JPanel desktop = new JPanel();
	JPanel principal = new JPanel();
	
	JButton cliente = new JButton("Cliente");
	JButton envio = new JButton("Envio");
	JButton boleto = new JButton("Boleto");
	JButton ajuda = new JButton("Ajuda");
	JButton sair = new JButton ("Sair");
	
	ImageIcon imagem = new ImageIcon ("f://imagemPrincipal.jpg");
	JLabel imagemUm = new JLabel(imagem);
	
	public SisGenEnc()
	{		
        principal.setLayout(null);   
        setSize(1000,700);   
                    
        desktop.setLayout(null);   
        desktop.setSize(1000, 987);   
        desktop.setBackground(new Color (0,0,0));   
        desktop.setBounds(0,30,1000,670);   

		setResizable(false);
		setTitle("Sistema de Gerenciamento de Encomendas");
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		add(principal);		
		principal.add(desktop);
						
		cliente.setFont(new Font("Times New Roman", Font.BOLD, 18));
		envio.setFont(new Font("Times New Roman", Font.BOLD, 18));
		boleto.setFont(new Font("Times New Roman", Font.BOLD, 18));
		ajuda.setFont(new Font("Times New Roman", Font.BOLD, 18));
		sair.setFont(new Font("Times New Roman", Font.BOLD, 18));
		
		cliente.setBounds(0, 0, 200, 30);
		envio.setBounds(200, 0, 200, 30);
		boleto.setBounds(400, 0, 200, 30);
		ajuda.setBounds(600, 0, 200, 30);
		sair.setBounds(800, 0, 200, 30);
								
		desktop.add(imagemUm);
		imagemUm.setBounds(200, 75, 600, 500);	
		
		principal.add(cliente);
		principal.add(envio);
		principal.add(boleto);
		principal.add(ajuda);
		principal.add(sair);
		
		cliente.addActionListener(this);
		envio.addActionListener(this);
		boleto.addActionListener(this);
		ajuda.addActionListener(this);
		sair.addActionListener(this);				
	}
	
	public static void main(String[] args) 
	{
		new SisGenEnc().setVisible(true);	
	}

	@Override
	public void actionPerformed(ActionEvent click) 
	{
		Object acao = click.getSource();	
		
		if (acao == cliente)
		{
			Cliente cliente = new Cliente();
		}
		if (acao == envio)
		{
			Envio envio = new Envio();
		}
		if (acao == boleto)
		{
			Boleto boleto = new Boleto();
		}
		if (acao == sair)
		{
			System.exit(0);
		}
		if (acao == ajuda)
		{			
			JOptionPane.showMessageDialog(null, "     Sistema Gerênciador de Encomendas"+"\n"
											   +"                           Versão 1.0" +"\n "
											   +"Desenvolvido por Cleyvison e Luis Antônio");
		}	
	}
}
package SisGenEnc;

import java.awt.Color;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.table.DefaultTableModel;
  
public class Cliente extends JFrame implements ActionListener
{
	private static final long serialVersionUID = 1L;   
	JPanel cliente = new JPanel();
	// componentes tela novo cliente
	JButton novo = new JButton("Novo");  
	JButton pesquisar = new JButton("Pesquisar");
	JButton salvar = new JButton("Salvar");   
	JButton cancelar = new JButton("Cancelar");   
	JButton sair = new JButton("Sair");
	
	JLabel codigo = new JLabel("Código: ");
	JLabel nome = new JLabel("Nome: ");
	JLabel rg = new JLabel("RG: ");
	JLabel cpf = new JLabel("CPF: ");
	JLabel telefone = new JLabel("Telefone: ");
	JLabel endereco = new JLabel("Endereço: ");
	JLabel numero = new JLabel("Número: ");
	JLabel bairro = new JLabel("Bairro: ");
	JLabel cidade = new JLabel("Cidade: ");
	JLabel estado = new JLabel("Estado: ");
	JLabel cep = new JLabel("CEP: ");
	
	JTextField _codigo = new JTextField(10);
	JTextField _nome = new JTextField(200);
	JTextField _rg = new JTextField(50);
	JTextField _cpf = new JTextField(20);
	JTextField _telefone = new JTextField(100);
	JTextField _endereco = new JTextField(100);
	JTextField _numero = new JTextField(30);
	JTextField _bairro = new JTextField(100);
	JTextField _cidade = new JTextField(100);
	JTextField _estado = new JTextField(40);
	JTextField _cep = new JTextField(30);
	private String Nome;
	private String Codigo;
	private String Rg;
	private String Cpf;
	private String Endereco;
	private String Numero;
	private String Bairro;
	private String Cidade;
	private String Estado;
	private String Cep;
	private String Telefone;
	// fim componentes tela novo cliente
	
	// inicio componentes tela pesquisa	
	JButton pesquisarExcluir = new JButton("Pesquisar");   
	JButton excluirCliente = new JButton("Excluir");   
	JButton cancelarExcluir = new JButton("Cancelar");   
	JButton sairExcluir = new JButton("Sair");
	JLabel insira = new JLabel("INFORME O CPF DO CLIENTE");
	JLabel cpfCliente = new JLabel("CPF: ");
	JTextField _cpfCliente = new JTextField(null, 20);
	
	JPanel painelBuscar = new JPanel(); 
	JPanel painelTable = new JPanel();
	JPanel painelBotoes = new JPanel();
	String cpfPesquisa = null;
	
	// fim componetes tela pesquisa
	
	private String nomeCliente;
	
    public Cliente() 
    {
    	super("Cliente");   
    	setTitle("Clientes");  
    	JPanel botoes = new JPanel();
   
    	botoes.setLayout(null);
    	add(cliente);
    	cliente.add(botoes);
    	    	
    	botoes.add(novo);
    	botoes.add(pesquisar);
    	
    	botoes.setBounds(0, 0, 800,30);
    	novo.setBounds(0, 0, 400, 30);
    	pesquisar.setBounds(400, 0, 400, 30);
    	setSize(800,600);
    	cliente.setSize(800,600);
    	setResizable(false);
    	cliente.setLayout(null);
    	setDefaultCloseOperation(DISPOSE_ON_CLOSE); 
    	
    	novo.addActionListener(this);
    	pesquisar.addActionListener(this);       	
        setVisible(true);   
    }
    public void setNome (String Nome)
    {
    	this.nomeCliente = Nome;
    }
    public String getNome ()
    {
    	return nomeCliente;
    }
    @Override
	public void actionPerformed(ActionEvent click)
    {
    	Object acaoBotao = click.getSource();
    	if (acaoBotao == novo)
    	{
    		// inicio tela novo cliente.
    		// esta tela deve ser mostrada quando o botão novo na tela de clientes for precionada
    		// e deverá ficar oculta quando o botão pesquisar for precionado
    		
    		cliente.add(sair);
        	cliente.add(salvar);
        	cliente.add(cancelar);
        	cliente.add(codigo);
        	cliente.add(nome);
        	cliente.add(rg);
        	cliente.add(cpf);
        	cliente.add(telefone);
        	cliente.add(endereco);
        	cliente.add(numero);
        	cliente.add(bairro);
        	cliente.add(cidade);
        	cliente.add(estado);
        	cliente.add(cep);
        	cliente.add(_codigo);
        	cliente.add(_nome);
        	cliente.add(_rg );
        	cliente.add(_cpf);
        	cliente.add(_telefone);
        	cliente.add(_endereco);
        	cliente.add(_numero);
        	cliente.add(_bairro);
        	cliente.add(_cidade);
        	cliente.add(_estado);
        	cliente.add(_cep);
        	
        	codigo.setFont(new Font("Times New Roman", Font.BOLD, 18));
        	nome.setFont(new Font("Times New Roman", Font.BOLD, 18));
        	rg.setFont(new Font("Times New Roman", Font.BOLD, 18));
        	cpf.setFont(new Font("Times New Roman", Font.BOLD, 18));
        	endereco.setFont(new Font("Times New Roman", Font.BOLD, 18));
        	numero.setFont(new Font("Times New Roman", Font.BOLD, 18));
        	bairro.setFont(new Font("Times New Roman", Font.BOLD, 18));
        	cidade.setFont(new Font("Times New Roman", Font.BOLD, 18));
        	estado.setFont(new Font("Times New Roman", Font.BOLD, 18));
        	cep.setFont(new Font("Times New Roman", Font.BOLD, 18));
        	telefone.setFont(new Font("Times New Roman", Font.BOLD, 18));
        	_codigo.setFont(new Font("Times New Roman", Font.BOLD, 18));
        	_nome.setFont(new Font("Times New Roman", Font.BOLD, 18));
        	_rg.setFont(new Font("Times New Roman", Font.BOLD, 18));
        	_cpf.setFont(new Font("Times New Roman", Font.BOLD, 18));
        	_endereco.setFont(new Font("Times New Roman", Font.BOLD, 18));
        	_numero.setFont(new Font("Times New Roman", Font.BOLD, 18));
        	_bairro.setFont(new Font("Times New Roman", Font.BOLD, 18));
        	_cidade.setFont(new Font("Times New Roman", Font.BOLD, 18));
        	_estado.setFont(new Font("Times New Roman", Font.BOLD, 18));
        	_cep.setFont(new Font("Times New Roman", Font.BOLD, 18));
        	_telefone.setFont(new Font("Times New Roman", Font.BOLD, 18));
        	
        	codigo.setBounds(30, 60, 100, 20);
        	nome.setBounds(30,100, 100, 20);
        	rg.setBounds(30, 140, 100, 20);
        	cpf.setBounds(420, 140, 100, 20);
        	telefone.setBounds(30, 180, 100, 20);
        	endereco.setBounds(30, 220, 100, 20);
        	numero.setBounds(420, 220, 100, 20);
        	bairro.setBounds(30, 260, 100, 20);
        	cidade.setBounds(30, 300, 100, 20);
        	estado.setBounds(420, 300, 100, 20);
        	cep.setBounds(30, 340, 100, 20);
        	_codigo.setBounds(120, 60, 100, 20);
        	_nome.setBounds(120,100, 650, 20);
        	_rg.setBounds(120, 140, 100, 20);
        	_cpf.setBounds(500, 140, 100, 20);
        	_telefone.setBounds(120, 180, 100, 20);
        	_endereco.setBounds(120, 220, 280, 20);
        	_numero.setBounds(500, 220, 100, 20);
        	_bairro.setBounds(120, 260, 280, 20);
        	_cidade.setBounds(120, 300, 280, 20);
        	_estado.setBounds(500, 300, 100, 20);
        	_cep.setBounds(120, 340, 100, 20);
        	salvar.setBounds(10, 460, 260, 40);
        	cancelar.setBounds(270, 460, 260, 40);
        	sair.setBounds(530, 460, 260, 40);
        	        	
        	salvar.addActionListener(this);
        	cancelar.addActionListener(this);
        	sair.addActionListener(this);
        	// fim da tela novo cliente
        	
        	// escondendo tela pesquisa
        	painelBuscar.setBounds(0, 0, 0, 0);
    		painelTable.setBounds(0, 0, 0, 0);
    		painelBotoes.setBounds(0, 0, 0, 0);
    		pesquisarExcluir.setBounds(0, 0, 0, 0);
        	excluirCliente.setBounds(0, 0, 0, 0);
        	cancelarExcluir.setBounds(0, 0, 0, 0);
        	sairExcluir.setBounds(0, 0, 0, 0);
        	insira.setBounds(0, 0, 0, 0);
        	cpfCliente.setBounds(0, 0, 0, 0);
        	_cpfCliente.setBounds(0, 0, 0, 0);
        	// fim esconder tela pesquisa
        }
    	// inicio tela pesquisa
    	
    	if(acaoBotao == pesquisar)
    	{
    		// escondendo os botoes da tela de clientes
    		codigo.setBounds(0, 0, 0, 0);
        	nome.setBounds(0, 0, 0, 0);
        	rg.setBounds(0, 0, 0, 0);
        	cpf.setBounds(0, 0, 0, 0);
        	telefone.setBounds(0, 0, 0, 0);
        	endereco.setBounds(0, 0, 0, 0);
        	numero.setBounds(0, 0, 0, 0);
        	bairro.setBounds(0, 0, 0, 0);
        	cidade.setBounds(0, 0, 0, 0);
        	estado.setBounds(0, 0, 0, 0);
        	cep.setBounds(0, 0, 0, 0);
        	_codigo.setBounds(0, 0, 0, 0);
        	_nome.setBounds(0, 0, 0, 0);
        	_rg.setBounds(0, 0, 0, 0);
        	_cpf.setBounds(0, 0, 0, 0);
        	_telefone.setBounds(0, 0, 0, 0);
        	_endereco.setBounds(0, 0, 0, 0);
        	_numero.setBounds(0, 0, 0, 0);
        	_bairro.setBounds(0, 0, 0, 0);
        	_cidade.setBounds(0, 0, 0, 0);
        	_estado.setBounds(0, 0, 0, 0);
        	_cep.setBounds(0, 0, 0, 0);
        	salvar.setBounds(0, 0, 0, 0);
        	cancelar.setBounds(0, 0, 0, 0);
        	sair.setBounds(0, 0, 0, 0);
        	/// fim esconder botoes tela cliente
        	
        	// inicio tela pesquisar cliente
        	DefaultTableModel modelo;
    		JScrollPane scrooll = new JScrollPane();
    		modelo = new DefaultTableModel();
    		
    		JTextField txtBuscar = new JTextField(10);
    		JTable tblBuscar = new JTable(modelo);
    		txtBuscar.setFont(new Font("Tahoma", Font.PLAIN, 12));
    				
    		modelo.addColumn("Código");
    		modelo.addColumn("Nome");
    		modelo.addColumn("Telefone");
    		modelo.addColumn("Endereço");
    		tblBuscar.getColumnModel().getColumn(0).setPreferredWidth(5);
    		scrooll.setViewportView(tblBuscar);
    		tblBuscar.setFont(new Font("Segoe UI", Font.PLAIN, 11));
    		tblBuscar.setSelectionBackground(Color.pink);
    		tblBuscar.setSelectionForeground(Color.blue);
    				    		
    		painelBotoes.setLayout(null);
    		painelBuscar.setLayout(null);
    		painelTable.setLayout(null);
    		setLayout(null);
    		
    		painelBuscar.add(insira);
    		painelBuscar.add(_cpfCliente);
    		painelBuscar.add(cpfCliente);
    		scrooll.setBounds (8, 30,780, 200);
    		painelTable.add(scrooll);
    		
    		painelBotoes.add(pesquisarExcluir);
    		painelBotoes.add(excluirCliente);
    		painelBotoes.add(cancelarExcluir);
    		painelBotoes.add(sairExcluir); 
    		    		
        	pesquisar.addActionListener(this);
        	excluirCliente.addActionListener(this);
        	cancelarExcluir.addActionListener(this);
        	sairExcluir.addActionListener(this);
       						
    		cliente.add(painelBuscar);
    		cliente.add(painelTable);
    		cliente.add(painelBotoes);
    		
    		painelBuscar.setBounds(100,50,500,95);
    		painelTable.setBounds(0,120,795,250);
    		painelBotoes.setBounds(0,450,795,50);
    		pesquisarExcluir.setBounds(10, 0, 195, 40);
        	excluirCliente.setBounds(205, 0, 195, 40);
        	cancelarExcluir.setBounds(400, 0, 195, 40);
        	sairExcluir.setBounds(595, 0, 195, 40);
        	insira.setBounds(0, 50, 400, 20);
        	_cpfCliente.setBounds(200, 50, 150, 20);

        }// fim tela pesquisar cliente
    	
    	if (acaoBotao == sair)
    	{
    		dispose();
    	}	
    	if (acaoBotao == sairExcluir)
    	{
    		dispose();
    	}	
    	
    	if (acaoBotao == salvar)
    	{
    		Codigo = _codigo.getText();
    		Rg =_rg.getText();
    		Cpf = _cpf.getText();
    		Endereco = _telefone.getText();
    		Numero = _endereco.getText();
    		Bairro = _numero.getText();
    		Cidade = _bairro.getText();
    		Estado = _cidade.getText();
    		Cep = _estado.getText();
    		Telefone = _cep.getText();    	
    	}
    
    	if (acaoBotao == pesquisar)
    	{
    		cpfPesquisa = _cpfCliente.getText();
      	}
	} 
}

depois que ele estiver pronto as redundâncias de nome, endereço etc… sairão…

um abraço espero contar com a ajuda dos senhores mais uma vez…

2 Respostas

cleyvison

bom dia, alguem poderia me dizer se o que fiz esta certo?

package SisGenEnc;

import java.awt.Color;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.table.DefaultTableModel;
  
public class Cliente extends JFrame implements ActionListener
{
	private static final long serialVersionUID = 1L;   
	JPanel cliente = new JPanel();
	// componentes tela novo cliente
	JButton novo = new JButton("Novo");  
	JButton pesquisar = new JButton("Pesquisar");
	JButton salvar = new JButton("Salvar");   
	JButton cancelar = new JButton("Cancelar");   
	JButton sair = new JButton("Sair");
	
	JLabel codigo = new JLabel("Código: ");
	JLabel nome = new JLabel("Nome: ");
	JLabel rg = new JLabel("RG: ");
	JLabel cpf = new JLabel("CPF: ");
	JLabel telefone = new JLabel("Telefone: ");
	JLabel endereco = new JLabel("Endereço: ");
	JLabel numero = new JLabel("Número: ");
	JLabel bairro = new JLabel("Bairro: ");
	JLabel cidade = new JLabel("Cidade: ");
	JLabel estado = new JLabel("Estado: ");
	JLabel cep = new JLabel("CEP: ");
	
	JTextField _codigo = new JTextField(10);
	JTextField _nome = new JTextField(200);
	JTextField _rg = new JTextField(50);
	JTextField _cpf = new JTextField(20);
	JTextField _telefone = new JTextField(100);
	JTextField _endereco = new JTextField(100);
	JTextField _numero = new JTextField(30);
	JTextField _bairro = new JTextField(100);
	JTextField _cidade = new JTextField(100);
	JTextField _estado = new JTextField(40);
	JTextField _cep = new JTextField(30);
	private static String Codigo;
	private static String Nome;
	private static String Rg;
	private static String Cpf;
	private static String Telefone;
	private static String Endereco;
	private static String Numero;
	private static String Bairro;
	private static String Cidade;
	private static String Estado;
	private static String Cep;
	
	// fim componentes tela novo cliente
	
	// inicio componentes tela pesquisa	
	JButton pesquisarExcluir = new JButton("Pesquisar");   
	JButton excluirCliente = new JButton("Excluir");   
	JButton cancelarExcluir = new JButton("Cancelar");   
	JButton sairExcluir = new JButton("Sair");
	JLabel insira = new JLabel("INFORME O CPF DO CLIENTE");
	JLabel cpfCliente = new JLabel("CPF: ");
	JTextField _cpfCliente = new JTextField(null, 20);
	
	JPanel painelBuscar = new JPanel(); 
	JPanel painelTable = new JPanel();
	JPanel painelBotoes = new JPanel();
	String cpfPesquisa = null;
	
	// fim componetes tela pesquisa
	
	private String nomeCliente;
	
    public Cliente() 
    {
    	super("Cliente");   
    	setTitle("Clientes");  
    	JPanel botoes = new JPanel();
   
    	botoes.setLayout(null);
    	add(cliente);
    	cliente.add(botoes);
    	    	
    	botoes.add(novo);
    	botoes.add(pesquisar);
    	
    	botoes.setBounds(0, 0, 800,30);
    	novo.setBounds(0, 0, 400, 30);
    	pesquisar.setBounds(400, 0, 400, 30);
    	setSize(800,600);
    	cliente.setSize(800,600);
    	setResizable(false);
    	cliente.setLayout(null);
    	setDefaultCloseOperation(DISPOSE_ON_CLOSE); 
    	
    	novo.addActionListener(this);
    	pesquisar.addActionListener(this);       	
        setVisible(true);   
    }
    public void setCodigo (String Codigo)
    {
    	this.Codigo = Codigo;
    }
    public static String getCodigo ()
    {
    	return Codigo;
    }
    public void setNome (String Nome)
    {
    	this.Nome = Nome;
    }
    public static String getNome ()
    {
    	return Nome;
    }
    public void setRg (String Rg)
    {
      	this.Rg = Rg;
    }
    public static String getRg ()
    {
      	return Rg;
    } 
    public void setCpf (String Cpf)
    {
       	this.Cpf = Cpf;
    }
    public static String getCpf ()
    {
      	return Cpf;
    }
    public void setTelefone (String Telefone)
    {
       	this.Telefone = Telefone;
    }
    public static String gettTelefone ()
    {
       	return Telefone;
    }
    public void setEndereco (String Endereco)
    {
       	this.Endereco = Endereco;
    }
    public static String gettEndereco ()
    {
       	return Endereco;
    }
    
    public void setNumero (String Numero)
    {
       	this.Numero  = Numero ;
    }
    public static String gettNumero  ()
    {
       	return Numero ;
    }
    public void setBairro (String Bairro)
    {
       	this.Bairro  = Bairro ;
    }
    public static String gettBairro  ()
    {
       	return Bairro ;
    }
    
    public void setCidade (String Cidade)
    {
       	this.Cidade  = Cidade ;
    }
    public static String gettCidade  ()
    {
       	return Cidade ;
    }
    public void setEstado (String Estado)
    {
       	this.Estado  = Estado ;
    }
    public static String gettEstado  ()
    {
       	return Estado ;
    }
    
    public void setCep (String Cep)
    {
       	this.Cep  = Cep ;
    }
    public static String gettCep ()
    {
       	return Cep ;
    }
    @Override
	public void actionPerformed(ActionEvent click)
    {
    	Object acaoBotao = click.getSource();
    	if (acaoBotao == novo)
    	{
    		// inicio tela novo cliente.
    		// esta tela deve ser mostrada quando o botão novo na tela de clientes for precionada
    		// e deverá ficar oculta quando o botão pesquisar for precionado
    		
    		cliente.add(sair);
        	cliente.add(salvar);
        	cliente.add(cancelar);
        	cliente.add(codigo);
        	cliente.add(nome);
        	cliente.add(rg);
        	cliente.add(cpf);
        	cliente.add(telefone);
        	cliente.add(endereco);
        	cliente.add(numero);
        	cliente.add(bairro);
        	cliente.add(cidade);
        	cliente.add(estado);
        	cliente.add(cep);
        	cliente.add(_codigo);
        	cliente.add(_nome);
        	cliente.add(_rg );
        	cliente.add(_cpf);
        	cliente.add(_telefone);
        	cliente.add(_endereco);
        	cliente.add(_numero);
        	cliente.add(_bairro);
        	cliente.add(_cidade);
        	cliente.add(_estado);
        	cliente.add(_cep);
        	
        	codigo.setFont(new Font("Times New Roman", Font.BOLD, 18));
        	nome.setFont(new Font("Times New Roman", Font.BOLD, 18));
        	rg.setFont(new Font("Times New Roman", Font.BOLD, 18));
        	cpf.setFont(new Font("Times New Roman", Font.BOLD, 18));
        	endereco.setFont(new Font("Times New Roman", Font.BOLD, 18));
        	numero.setFont(new Font("Times New Roman", Font.BOLD, 18));
        	bairro.setFont(new Font("Times New Roman", Font.BOLD, 18));
        	cidade.setFont(new Font("Times New Roman", Font.BOLD, 18));
        	estado.setFont(new Font("Times New Roman", Font.BOLD, 18));
        	cep.setFont(new Font("Times New Roman", Font.BOLD, 18));
        	telefone.setFont(new Font("Times New Roman", Font.BOLD, 18));
        	_codigo.setFont(new Font("Times New Roman", Font.BOLD, 18));
        	_nome.setFont(new Font("Times New Roman", Font.BOLD, 18));
        	_rg.setFont(new Font("Times New Roman", Font.BOLD, 18));
        	_cpf.setFont(new Font("Times New Roman", Font.BOLD, 18));
        	_endereco.setFont(new Font("Times New Roman", Font.BOLD, 18));
        	_numero.setFont(new Font("Times New Roman", Font.BOLD, 18));
        	_bairro.setFont(new Font("Times New Roman", Font.BOLD, 18));
        	_cidade.setFont(new Font("Times New Roman", Font.BOLD, 18));
        	_estado.setFont(new Font("Times New Roman", Font.BOLD, 18));
        	_cep.setFont(new Font("Times New Roman", Font.BOLD, 18));
        	_telefone.setFont(new Font("Times New Roman", Font.BOLD, 18));
        	
        	codigo.setBounds(30, 60, 100, 20);
        	nome.setBounds(30,100, 100, 20);
        	rg.setBounds(30, 140, 100, 20);
        	cpf.setBounds(420, 140, 100, 20);
        	telefone.setBounds(30, 180, 100, 20);
        	endereco.setBounds(30, 220, 100, 20);
        	numero.setBounds(420, 220, 100, 20);
        	bairro.setBounds(30, 260, 100, 20);
        	cidade.setBounds(30, 300, 100, 20);
        	estado.setBounds(420, 300, 100, 20);
        	cep.setBounds(30, 340, 100, 20);
        	_codigo.setBounds(120, 60, 100, 20);
        	_nome.setBounds(120,100, 650, 20);
        	_rg.setBounds(120, 140, 100, 20);
        	_cpf.setBounds(500, 140, 100, 20);
        	_telefone.setBounds(120, 180, 100, 20);
        	_endereco.setBounds(120, 220, 280, 20);
        	_numero.setBounds(500, 220, 100, 20);
        	_bairro.setBounds(120, 260, 280, 20);
        	_cidade.setBounds(120, 300, 280, 20);
        	_estado.setBounds(500, 300, 100, 20);
        	_cep.setBounds(120, 340, 100, 20);
        	salvar.setBounds(10, 460, 260, 40);
        	cancelar.setBounds(270, 460, 260, 40);
        	sair.setBounds(530, 460, 260, 40);
        	        	
        	salvar.addActionListener(this);
        	cancelar.addActionListener(this);
        	sair.addActionListener(this);
        	// fim da tela novo cliente
        	
        	// escondendo tela pesquisa
        	painelBuscar.setBounds(0, 0, 0, 0);
    		painelTable.setBounds(0, 0, 0, 0);
    		painelBotoes.setBounds(0, 0, 0, 0);
    		pesquisarExcluir.setBounds(0, 0, 0, 0);
        	excluirCliente.setBounds(0, 0, 0, 0);
        	cancelarExcluir.setBounds(0, 0, 0, 0);
        	sairExcluir.setBounds(0, 0, 0, 0);
        	insira.setBounds(0, 0, 0, 0);
        	cpfCliente.setBounds(0, 0, 0, 0);
        	_cpfCliente.setBounds(0, 0, 0, 0);
        	// fim esconder tela pesquisa
        }
    	// inicio tela pesquisa
    	
    	if(acaoBotao == pesquisar)
    	{
    		// escondendo os botoes da tela de clientes
    		codigo.setBounds(0, 0, 0, 0);
        	nome.setBounds(0, 0, 0, 0);
        	rg.setBounds(0, 0, 0, 0);
        	cpf.setBounds(0, 0, 0, 0);
        	telefone.setBounds(0, 0, 0, 0);
        	endereco.setBounds(0, 0, 0, 0);
        	numero.setBounds(0, 0, 0, 0);
        	bairro.setBounds(0, 0, 0, 0);
        	cidade.setBounds(0, 0, 0, 0);
        	estado.setBounds(0, 0, 0, 0);
        	cep.setBounds(0, 0, 0, 0);
        	_codigo.setBounds(0, 0, 0, 0);
        	_nome.setBounds(0, 0, 0, 0);
        	_rg.setBounds(0, 0, 0, 0);
        	_cpf.setBounds(0, 0, 0, 0);
        	_telefone.setBounds(0, 0, 0, 0);
        	_endereco.setBounds(0, 0, 0, 0);
        	_numero.setBounds(0, 0, 0, 0);
        	_bairro.setBounds(0, 0, 0, 0);
        	_cidade.setBounds(0, 0, 0, 0);
        	_estado.setBounds(0, 0, 0, 0);
        	_cep.setBounds(0, 0, 0, 0);
        	salvar.setBounds(0, 0, 0, 0);
        	cancelar.setBounds(0, 0, 0, 0);
        	sair.setBounds(0, 0, 0, 0);
        	/// fim esconder botoes tela cliente
        	
        	// inicio tela pesquisar cliente
        	DefaultTableModel modelo;
    		JScrollPane scrooll = new JScrollPane();
    		modelo = new DefaultTableModel();
    		
    		JTextField txtBuscar = new JTextField(10);
    		JTable tblBuscar = new JTable(modelo);
    		txtBuscar.setFont(new Font("Tahoma", Font.PLAIN, 12));
    				
    		modelo.addColumn("Código");
    		modelo.addColumn("Nome");
    		modelo.addColumn("Telefone");
    		modelo.addColumn("Endereço");
    		tblBuscar.getColumnModel().getColumn(0).setPreferredWidth(5);
    		scrooll.setViewportView(tblBuscar);
    		tblBuscar.setFont(new Font("Segoe UI", Font.PLAIN, 11));
    		tblBuscar.setSelectionBackground(Color.pink);
    		tblBuscar.setSelectionForeground(Color.blue);
    				    		
    		painelBotoes.setLayout(null);
    		painelBuscar.setLayout(null);
    		painelTable.setLayout(null);
    		setLayout(null);
    		
    		painelBuscar.add(insira);
    		painelBuscar.add(_cpfCliente);
    		painelBuscar.add(cpfCliente);
    		scrooll.setBounds (8, 30,780, 200);
    		painelTable.add(scrooll);
    		
    		painelBotoes.add(pesquisarExcluir);
    		painelBotoes.add(excluirCliente);
    		painelBotoes.add(cancelarExcluir);
    		painelBotoes.add(sairExcluir); 
    		    		
        	pesquisar.addActionListener(this);
        	excluirCliente.addActionListener(this);
        	cancelarExcluir.addActionListener(this);
        	sairExcluir.addActionListener(this);
       						
    		cliente.add(painelBuscar);
    		cliente.add(painelTable);
    		cliente.add(painelBotoes);
    		
    		painelBuscar.setBounds(100,50,500,95);
    		painelTable.setBounds(0,120,795,250);
    		painelBotoes.setBounds(0,450,795,50);
    		pesquisarExcluir.setBounds(10, 0, 195, 40);
        	excluirCliente.setBounds(205, 0, 195, 40);
        	cancelarExcluir.setBounds(400, 0, 195, 40);
        	sairExcluir.setBounds(595, 0, 195, 40);
        	insira.setBounds(0, 50, 400, 20);
        	_cpfCliente.setBounds(200, 50, 150, 20);

        }// fim tela pesquisar cliente
    	
    	if (acaoBotao == sair)
    	{
    		dispose();
    	}	
    	if (acaoBotao == sairExcluir)
    	{
    		dispose();
    	}	
    	
    	if (acaoBotao == salvar)
    	{
    		Codigo = _codigo.getText();
    		Nome = _nome.getText();
    		Rg =_rg.getText();
    		Cpf = _cpf.getText();
    		Endereco = _telefone.getText();
    		Numero = _endereco.getText();
    		Bairro = _numero.getText();
    		Cidade = _bairro.getText();
    		Estado = _cidade.getText();
    		Cep = _estado.getText();
    		Telefone = _cep.getText();   
    	}
    
    	if (acaoBotao == pesquisar)
    	{
    		cpfPesquisa = _cpfCliente.getText();
      	}
	} 
}

qquado coloco

System.out.println(" teste"+Cliente.Nome);

na calsse boleto por exemplo me retorna que esta variavel não esta visivel.

qdo coloco

System.out.println(" teste"+Cliente.getNome());

imprimi o valor…
mas, a implementação, esta correta?

C

voce tem que ter uma classe com a declaracao dos getters e setters…

exemplo

public class Cliente {

private String nome;
private String endereco;



    public String setNome(String nome){
             this.nome = nome;
    }
public String getNome() {
	return nome;
}
public void setEndereco(String endereco) {
	this.endereco = endereco ;
}
public String getEndereco() {
	return endereco;
}

}

Criado 4 de julho de 2009
Ultima resposta 5 de jul. de 2009
Respostas 2
Participantes 2