Olá, javaflex!
Estou usando o Swing. Vou colar aqui o codigo da Classe TelaPessoas.
package View;
import java.awt.BorderLayout;
import java.util.ArrayList;
import java.util.List;
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.UIManager;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.SwingConstants;
import javax.swing.JComboBox;
import javax.swing.JList;
import javax.swing.JOptionPane;
import javax.swing.border.CompoundBorder;
import javax.swing.border.LineBorder;
import javax.swing.table.TableColumn;
import javax.swing.text.MaskFormatter;
import Controle.CTRpessoa;
import Controle.CTRtelefone;
import Controle.CTRendereco;
import Modelo.Telefone;
import Modelo.Endereco;
import Modelo.Pessoas;
import Modelo.TabelaJ;
import java.awt.Color;
import javax.swing.AbstractListModel;
import javax.swing.DefaultCellEditor;
import javax.swing.JTable;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JButton;
import javax.swing.ImageIcon;
import java.awt.event.ActionListener;
import java.text.ParseException;
import java.awt.event.ActionEvent;
import javax.swing.JScrollPane;
import java.awt.Font;
import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.JFormattedTextField;
public class TelaPessoas extends JFrame {
private JPanel contentPane;
private JTextField txtCodigo;
private JTextField txtNome;
private JTextField txtEndereco;
private JTextField txtNumero;
private JTextField txtBairro;
private JFormattedTextField txtCep;
private JTable tblFone;
private JFormattedTextField txtTelefone;
private TabelaJ tabelaFone;
private JTextField txtComplemento;
private JFormattedTextField txtCPF;
private JFormattedTextField txtRG;
private final Action action = new SwingAction();
private JFormattedTextField txtExp;
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
TelaPessoas frame = new TelaPessoas();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the frame.
* @throws ParseException
*/
public TelaPessoas() throws ParseException {
setTitle("Imobili\u00E1ria :: Cadastro de Pessoas");
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
setBounds(100, 100, 682, 480);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null);
setLocationRelativeTo(null);
List<Telefone> ListFone = new ArrayList<Telefone>();
CTRpessoa codpessoa = new CTRpessoa();
JPanel panel = new JPanel();
panel.setBounds(10, 11, 650, 423);
contentPane.add(panel);
panel.setLayout(null);
JLabel lblCodigo = new JLabel("C\u00F3digo");
lblCodigo.setHorizontalAlignment(SwingConstants.RIGHT);
lblCodigo.setBounds(50, 11, 46, 14);
panel.add(lblCodigo);
txtCodigo = new JTextField();
txtCodigo.setHorizontalAlignment(SwingConstants.RIGHT);
txtCodigo.setBounds(106, 8, 86, 20);
panel.add(txtCodigo);
txtCodigo.setColumns(10);
//txtCodigo.setText(codpessoa.trataCodigo());
txtCodigo.setText(String.format("%06d",Integer.parseInt(codpessoa.trataCodigo())));
JLabel lblNome = new JLabel("Nome");
lblNome.setHorizontalAlignment(SwingConstants.RIGHT);
lblNome.setBounds(50, 36, 46, 14);
panel.add(lblNome);
txtNome = new JTextField();
txtNome.setBounds(106, 33, 529, 20);
panel.add(txtNome);
txtNome.setColumns(10);
JLabel lblEndereco = new JLabel("Endere\u00E7o");
lblEndereco.setHorizontalAlignment(SwingConstants.RIGHT);
lblEndereco.setBounds(30, 61, 66, 14);
panel.add(lblEndereco);
txtEndereco = new JTextField();
txtEndereco.setBounds(106, 58, 345, 20);
panel.add(txtEndereco);
txtEndereco.setColumns(10);
JLabel lblNumero = new JLabel("N\u00FAmero");
lblNumero.setHorizontalAlignment(SwingConstants.RIGHT);
lblNumero.setBounds(458, 61, 46, 14);
panel.add(lblNumero);
txtNumero = new JTextField();
txtNumero.setBounds(514, 58, 121, 20);
panel.add(txtNumero);
txtNumero.setColumns(10);
JLabel lblBairro = new JLabel("Bairro");
lblBairro.setHorizontalAlignment(SwingConstants.RIGHT);
lblBairro.setBounds(50, 113, 46, 14);
panel.add(lblBairro);
txtBairro = new JTextField();
txtBairro.setBounds(107, 110, 214, 20);
panel.add(txtBairro);
txtBairro.setColumns(10);
JLabel lblCidade = new JLabel("Cidade");
lblCidade.setHorizontalAlignment(SwingConstants.RIGHT);
lblCidade.setBounds(319, 113, 46, 14);
panel.add(lblCidade);
JLabel lblCep = new JLabel("CEP");
lblCep.setHorizontalAlignment(SwingConstants.RIGHT);
lblCep.setBounds(496, 86, 46, 14);
panel.add(lblCep);
txtCep = new JFormattedTextField(new MaskFormatter("#####-###"));
txtCep.setBounds(549, 83, 86, 20);
panel.add(txtCep);
txtCep.setColumns(10);
txtCep.setFocusLostBehavior(JFormattedTextField.COMMIT);
JLabel lblUF = new JLabel("UF");
lblUF.setHorizontalAlignment(SwingConstants.RIGHT);
lblUF.setBounds(524, 113, 46, 14);
panel.add(lblUF);
JComboBox cbCidade = new JComboBox();
cbCidade.setModel(new DefaultComboBoxModel(new String[] {"Presidente Prudente"}));
cbCidade.setBounds(375, 110, 176, 20);
panel.add(cbCidade);
JComboBox cbUf = new JComboBox();
cbUf.setModel(new DefaultComboBoxModel(new String[] {"SP"}));
cbUf.setBounds(580, 110, 55, 20);
panel.add(cbUf);
JLabel lblTelefone = new JLabel("Telefone");
lblTelefone.setHorizontalAlignment(SwingConstants.RIGHT);
lblTelefone.setBounds(41, 172, 55, 14);
panel.add(lblTelefone);
JLabel lblTipoTel = new JLabel("Tipo Telefone");
lblTipoTel.setHorizontalAlignment(SwingConstants.RIGHT);
lblTipoTel.setBounds(254, 172, 92, 14);
panel.add(lblTipoTel);
txtTelefone = new JFormattedTextField(new MaskFormatter("(##)#####-####"));
txtTelefone.setBounds(107, 169, 147, 20);
panel.add(txtTelefone);
txtTelefone.setColumns(10);
txtTelefone.setFocusLostBehavior(JFormattedTextField.COMMIT);
JComboBox cbTipoFone = new JComboBox();
cbTipoFone.setModel(new DefaultComboBoxModel(new String[] {"Residencial", "Comercial", "Celular ", "Fax", "Outros"}));
cbTipoFone.setBounds(353, 169, 163, 20);
panel.add(cbTipoFone);
JButton btnAdcTel = new JButton("");
btnAdcTel.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
Telefone tel = new Telefone(0);
Telefone fone = new Telefone(ListFone.size()+1);
tel.setNumFone(txtTelefone.getText());
tel.setTipo(cbTipoFone.getSelectedItem().toString());
ListFone.add(ListFone.size(),tel);
//Passando array por parâmetro para a classe TabelaJ
tabelaFone = new TabelaJ(ListFone);
//Setando o modelo que será usado, no caso a classe/modelo tabelaJ = tabelafone
tblFone.setModel(tabelaFone);
trocaTipoFone(tblFone.getColumnModel().getColumn(1));
txtTelefone.setText("");
}
});
btnAdcTel.setIcon(new ImageIcon(TelaPessoas.class.getResource("/Imagens/Create.png")));
btnAdcTel.setBounds(518, 167, 24, 24);
panel.add(btnAdcTel);
JButton btnCancelar = new JButton("Cancelar");
btnCancelar.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
dispose();
}
});
btnCancelar.setBounds(546, 381, 89, 23);
panel.add(btnCancelar);
JButton btnSalvar = new JButton("Salvar");
btnSalvar.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
try{
int codigo = Integer.parseInt(txtCodigo.getText());
String nome = txtNome.getText();
String cpf = txtCPF.getText();
String rg = txtRG.getText();
String exp = txtExp.getText();
CTRpessoa ctrpessoa = new CTRpessoa();
ctrpessoa.gravaPessoa(codigo, nome, cpf, rg, exp);
String logradouro = txtEndereco.getText();
String numero = txtNumero.getText();
String bairro = txtBairro.getText();
String cep = txtCep.getText();
String complemento = txtComplemento.getText();
String cidade = cbCidade.getSelectedItem().toString();
String uf = cbUf.getSelectedItem().toString();
int codPessoa = Integer.parseInt(txtCodigo.getText());
CTRendereco ctrendereco = new CTRendereco();
ctrendereco.gravaEndereco(logradouro, numero, bairro, cep, complemento, cidade, uf, codPessoa);
List<Telefone> fone = new ArrayList<Telefone>();
for(int i=0; i<tblFone.getRowCount(); i++){
Telefone tel = new Telefone();
tel.setNumFone(tblFone.getValueAt(i, 0).toString());
tel.setTipo(tblFone.getValueAt(i, 1).toString());
tel.setCodPessoa(codPessoa);
fone.add(fone.size(),tel);
}
CTRtelefone ctrtelefone = new CTRtelefone();
ctrtelefone.gravaTelefone(fone);
JOptionPane.showMessageDialog(null,"Cadastro realizado com Sucesso!");
ListFone.clear();
limpaCampos();
}catch(Exception f){
JOptionPane.showMessageDialog(null,"Erro: "+f.getMessage());
}
}
});
btnSalvar.setBounds(452, 381, 89, 23);
panel.add(btnSalvar);
JButton btnAlterar = new JButton("Limpar");
btnAlterar.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
limpaCampos();
}
});
btnAlterar.setBounds(357, 381, 89, 23);
panel.add(btnAlterar);
JScrollPane scrollPane = new JScrollPane();
scrollPane.setBounds(106, 211, 529, 141);
panel.add(scrollPane);
tabelaFone = new TabelaJ();
tblFone = new JTable();
scrollPane.setViewportView(tblFone);
tblFone.setModel(tabelaFone);
trocaTipoFone(tblFone.getColumnModel().getColumn(1));
JButton txtRemoveFone = new JButton("");
txtRemoveFone.setIcon(new ImageIcon(TelaPessoas.class.getResource("/Imagens/No-entry.png")));
txtRemoveFone.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
int rmLinha=0;
if(tblFone.getSelectedRow()!= -1)
rmLinha = tblFone.getSelectedRow();
tabelaFone.removeFone(tblFone.getSelectedRow());
ListFone.remove(rmLinha);
}
});
txtRemoveFone.setBounds(106, 353, 24, 24);
panel.add(txtRemoveFone);
JLabel lblRemoveNumero = new JLabel("(Remove N\u00FAmero)");
lblRemoveNumero.setForeground(Color.RED);
lblRemoveNumero.setHorizontalAlignment(SwingConstants.LEFT);
lblRemoveNumero.setFont(new Font("Arial", Font.BOLD, 10));
lblRemoveNumero.setBounds(133, 358, 121, 14);
panel.add(lblRemoveNumero);
txtComplemento = new JTextField();
txtComplemento.setColumns(10);
txtComplemento.setBounds(106, 83, 398, 20);
panel.add(txtComplemento);
JLabel lblComplemento = new JLabel("Complemento");
lblComplemento.setHorizontalAlignment(SwingConstants.RIGHT);
lblComplemento.setBounds(4, 86, 92, 14);
panel.add(lblComplemento);
txtCPF = new JFormattedTextField(new MaskFormatter("###.###.###.##"));
txtCPF.setColumns(10);
txtCPF.setBounds(107, 138, 176, 20);
panel.add(txtCPF);
txtCPF.setFocusLostBehavior(JFormattedTextField.COMMIT);
JLabel lblCPF = new JLabel("CPF");
lblCPF.setHorizontalAlignment(SwingConstants.RIGHT);
lblCPF.setBounds(50, 141, 46, 14);
panel.add(lblCPF);
txtRG = new JFormattedTextField(new MaskFormatter("##.###.###-##"));
txtRG.setColumns(10);
txtRG.setBounds(329, 138, 175, 20);
panel.add(txtRG);
txtRG.setFocusLostBehavior(JFormattedTextField.COMMIT);
JLabel lblRG = new JLabel("RG");
lblRG.setHorizontalAlignment(SwingConstants.RIGHT);
lblRG.setBounds(275, 141, 46, 14);
panel.add(lblRG);
txtExp = new JFormattedTextField(new MaskFormatter("UUU/UU"));
txtExp.setColumns(10);
txtExp.setBounds(549, 138, 86, 20);
panel.add(txtExp);
txtExp.setFocusLostBehavior(JFormattedTextField.COMMIT);
JLabel lblExp = new JLabel("Exp.");
lblExp.setHorizontalAlignment(SwingConstants.RIGHT);
lblExp.setBounds(496, 141, 46, 14);
panel.add(lblExp);
}
//-----------------------------------------------Constructor para dados --------------------------------
public TelaPessoas(Pessoas p, Endereco e, Telefone t) throws ParseException {
setTitle(“Imobili\u00E1ria :: Cadastro de Pessoas”);
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
setBounds(100, 100, 682, 480);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null);
setLocationRelativeTo(null);
List<Telefone> ListFone = new ArrayList<Telefone>();
CTRpessoa codpessoa = new CTRpessoa();
JPanel panel = new JPanel();
panel.setBounds(10, 11, 650, 423);
contentPane.add(panel);
panel.setLayout(null);
JLabel lblCodigo = new JLabel("C\u00F3digo");
lblCodigo.setHorizontalAlignment(SwingConstants.RIGHT);
lblCodigo.setBounds(50, 11, 46, 14);
panel.add(lblCodigo);
txtCodigo = new JTextField();
txtCodigo.setHorizontalAlignment(SwingConstants.RIGHT);
txtCodigo.setBounds(106, 8, 86, 20);
panel.add(txtCodigo);
txtCodigo.setColumns(10);
//txtCodigo.setText(Integer.toString(p.getCodigo()));
txtCodigo.setText(String.format("%06d",(p.getCodigo())));
JLabel lblNome = new JLabel("Nome");
lblNome.setHorizontalAlignment(SwingConstants.RIGHT);
lblNome.setBounds(50, 36, 46, 14);
panel.add(lblNome);
txtNome = new JTextField();
txtNome.setBounds(106, 33, 529, 20);
panel.add(txtNome);
txtNome.setColumns(10);
txtNome.setText(p.getNome());
JLabel lblEndereco = new JLabel("Endere\u00E7o");
lblEndereco.setHorizontalAlignment(SwingConstants.RIGHT);
lblEndereco.setBounds(30, 61, 66, 14);
panel.add(lblEndereco);
txtEndereco = new JTextField();
txtEndereco.setBounds(106, 58, 345, 20);
panel.add(txtEndereco);
txtEndereco.setColumns(10);
txtEndereco.setText(e.getLogradouro());
JLabel lblNumero = new JLabel("N\u00FAmero");
lblNumero.setHorizontalAlignment(SwingConstants.RIGHT);
lblNumero.setBounds(458, 61, 46, 14);
panel.add(lblNumero);
txtNumero = new JTextField();
txtNumero.setBounds(514, 58, 121, 20);
panel.add(txtNumero);
txtNumero.setColumns(10);
txtNumero.setText(e.getNumero());
JLabel lblBairro = new JLabel("Bairro");
lblBairro.setHorizontalAlignment(SwingConstants.RIGHT);
lblBairro.setBounds(50, 113, 46, 14);
panel.add(lblBairro);
txtBairro = new JTextField();
txtBairro.setBounds(107, 110, 214, 20);
panel.add(txtBairro);
txtBairro.setColumns(10);
txtBairro.setText(e.getBairro());
JLabel lblCidade = new JLabel("Cidade");
lblCidade.setHorizontalAlignment(SwingConstants.RIGHT);
lblCidade.setBounds(319, 113, 46, 14);
panel.add(lblCidade);
JLabel lblCep = new JLabel("CEP");
lblCep.setHorizontalAlignment(SwingConstants.RIGHT);
lblCep.setBounds(496, 86, 46, 14);
panel.add(lblCep);
txtCep = new JFormattedTextField(new MaskFormatter("#####-###"));
txtCep.setBounds(549, 83, 86, 20);
panel.add(txtCep);
txtCep.setColumns(10);
txtCep.setFocusLostBehavior(JFormattedTextField.COMMIT);
txtCep.setText(e.getCep());
JLabel lblUF = new JLabel("UF");
lblUF.setHorizontalAlignment(SwingConstants.RIGHT);
lblUF.setBounds(524, 113, 46, 14);
panel.add(lblUF);
JComboBox cbCidade = new JComboBox();
cbCidade.setModel(new DefaultComboBoxModel(new String[] {"Presidente Prudente"}));
cbCidade.setBounds(375, 110, 176, 20);
panel.add(cbCidade);
JComboBox cbUf = new JComboBox();
cbUf.setModel(new DefaultComboBoxModel(new String[] {e.getUf()}));
cbUf.setBounds(580, 110, 55, 20);
panel.add(cbUf);
JLabel lblTelefone = new JLabel("Telefone");
lblTelefone.setHorizontalAlignment(SwingConstants.RIGHT);
lblTelefone.setBounds(41, 172, 55, 14);
panel.add(lblTelefone);
JLabel lblTipoTel = new JLabel("Tipo Telefone");
lblTipoTel.setHorizontalAlignment(SwingConstants.RIGHT);
lblTipoTel.setBounds(254, 172, 92, 14);
panel.add(lblTipoTel);
txtTelefone = new JFormattedTextField(new MaskFormatter("(##)#####-####"));
txtTelefone.setBounds(107, 169, 147, 20);
panel.add(txtTelefone);
txtTelefone.setColumns(10);
txtTelefone.setFocusLostBehavior(JFormattedTextField.COMMIT);
JComboBox cbTipoFone = new JComboBox();
cbTipoFone.setModel(new DefaultComboBoxModel(new String[] {"Residencial", "Comercial", "Celular ", "Fax", "Outros"}));
cbTipoFone.setBounds(353, 169, 163, 20);
panel.add(cbTipoFone);
JButton btnAdcTel = new JButton("");
btnAdcTel.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
Telefone tel = new Telefone(0);
Telefone fone = new Telefone(ListFone.size()+1);
tel.setNumFone(txtTelefone.getText());
tel.setTipo(cbTipoFone.getSelectedItem().toString());
ListFone.add(ListFone.size(),tel);
//Passando array por parâmetro para a classe TabelaJ
tabelaFone = new TabelaJ(ListFone);
//Setando o modelo que será usado, no caso a classe/modelo tabelaJ = tabelafone
tblFone.setModel(tabelaFone);
trocaTipoFone(tblFone.getColumnModel().getColumn(1));
txtTelefone.setText("");
}
});
btnAdcTel.setIcon(new ImageIcon(TelaPessoas.class.getResource("/Imagens/Create.png")));
btnAdcTel.setBounds(518, 167, 24, 24);
panel.add(btnAdcTel);
JButton btnCancelar = new JButton("Cancelar");
btnCancelar.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
dispose();
}
});
btnCancelar.setBounds(546, 381, 89, 23);
panel.add(btnCancelar);
JButton btnSalvar = new JButton("Salvar");
btnSalvar.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
try{
int codigo = Integer.parseInt(txtCodigo.getText());
String nome = txtNome.getText();
String cpf = txtCPF.getText();
String rg = txtRG.getText();
String exp = txtExp.getText();
CTRpessoa ctrpessoa = new CTRpessoa();
ctrpessoa.atualizaPessoa(codigo, nome, cpf, rg, exp);
String logradouro = txtEndereco.getText();
String numero = txtNumero.getText();
String bairro = txtBairro.getText();
String cep = txtCep.getText();
String complemento = txtComplemento.getText();
String cidade = cbCidade.getSelectedItem().toString();
String uf = cbUf.getSelectedItem().toString();
int codPessoa = Integer.parseInt(txtCodigo.getText());
CTRendereco ctrendereco = new CTRendereco();
ctrendereco.atualizaEndereco(logradouro, numero, bairro, cep, complemento, cidade, uf, codPessoa);
List<Telefone> fone = new ArrayList<Telefone>();
for(int i=0; i<tblFone.getRowCount(); i++){
Telefone tel = new Telefone();
tel.setNumFone(tblFone.getValueAt(i, 0).toString());
tel.setTipo(tblFone.getValueAt(i, 1).toString());
tel.setCodPessoa(codPessoa);
fone.add(fone.size(),tel);
}
CTRtelefone ctrtelefone = new CTRtelefone();
ctrtelefone.atualizaTelefone(fone);
JOptionPane.showMessageDialog(null,"Cadastro realizado com Sucesso!");
ListFone.clear();
limpaCampos();
}catch(Exception f){
JOptionPane.showMessageDialog(null,"Erro: "+f.getMessage());
}
}
});
btnSalvar.setBounds(452, 381, 89, 23);
panel.add(btnSalvar);
JButton btnAlterar = new JButton("Alterar");
btnAlterar.setBounds(357, 381, 89, 23);
panel.add(btnAlterar);
JScrollPane scrollPane = new JScrollPane();
scrollPane.setBounds(106, 211, 529, 141);
panel.add(scrollPane);
tabelaFone = new TabelaJ();
tblFone = new JTable();
scrollPane.setViewportView(tblFone);
tblFone.setModel(tabelaFone);
trocaTipoFone(tblFone.getColumnModel().getColumn(1));
JButton txtRemoveFone = new JButton("");
txtRemoveFone.setIcon(new ImageIcon(TelaPessoas.class.getResource("/Imagens/No-entry.png")));
txtRemoveFone.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
int rmLinha=0;
if(tblFone.getSelectedRow()!= -1)
rmLinha = tblFone.getSelectedRow();
tabelaFone.removeFone(tblFone.getSelectedRow());
ListFone.remove(rmLinha);
}
});
txtRemoveFone.setBounds(106, 353, 24, 24);
panel.add(txtRemoveFone);
JLabel lblRemoveNumero = new JLabel("(Remove N\u00FAmero)");
lblRemoveNumero.setForeground(Color.RED);
lblRemoveNumero.setHorizontalAlignment(SwingConstants.LEFT);
lblRemoveNumero.setFont(new Font("Arial", Font.BOLD, 10));
lblRemoveNumero.setBounds(133, 358, 121, 14);
panel.add(lblRemoveNumero);
txtComplemento = new JTextField();
txtComplemento.setColumns(10);
txtComplemento.setBounds(106, 83, 398, 20);
panel.add(txtComplemento);
txtComplemento.setText(e.getComplemento());
JLabel lblComplemento = new JLabel("Complemento");
lblComplemento.setHorizontalAlignment(SwingConstants.RIGHT);
lblComplemento.setBounds(4, 86, 92, 14);
panel.add(lblComplemento);
txtCPF = new JFormattedTextField(new MaskFormatter("###.###.###.##"));
txtCPF.setColumns(10);
txtCPF.setBounds(107, 138, 176, 20);
panel.add(txtCPF);
txtCPF.setText(p.getCpf());
txtCPF.setFocusLostBehavior(JFormattedTextField.COMMIT);
JLabel lblCPF = new JLabel("CPF");
lblCPF.setHorizontalAlignment(SwingConstants.RIGHT);
lblCPF.setBounds(50, 141, 46, 14);
panel.add(lblCPF);
txtRG = new JFormattedTextField(new MaskFormatter("##.###.###-##"));
txtRG.setColumns(10);
txtRG.setBounds(329, 138, 175, 20);
panel.add(txtRG);
txtRG.setText(p.getRg());
txtRG.setFocusLostBehavior(JFormattedTextField.COMMIT);
JLabel lblRG = new JLabel("RG");
lblRG.setHorizontalAlignment(SwingConstants.RIGHT);
lblRG.setBounds(275, 141, 46, 14);
panel.add(lblRG);
txtExp = new JFormattedTextField(new MaskFormatter("UUU/UU"));
txtExp.setColumns(10);
txtExp.setBounds(549, 138, 86, 20);
panel.add(txtExp);
txtExp.setText(p.getExpedidor());
txtExp.setFocusLostBehavior(JFormattedTextField.COMMIT);
JLabel lblExp = new JLabel("Exp.");
lblExp.setHorizontalAlignment(SwingConstants.RIGHT);
lblExp.setBounds(496, 141, 46, 14);
panel.add(lblExp);
}
private void trocaTipoFone(TableColumn tipo){
JComboBox<String> cbAlteraTipoFone = new JComboBox<String>();
cbAlteraTipoFone.addItem("Residencial");
cbAlteraTipoFone.addItem("Comercial");
cbAlteraTipoFone.addItem("Celular");
cbAlteraTipoFone.addItem("Fax");
cbAlteraTipoFone.addItem("Outros");
tipo.setCellEditor(new DefaultCellEditor(cbAlteraTipoFone));
}
private class SwingAction extends AbstractAction {
public SwingAction() {
putValue(NAME, "SwingAction");
putValue(SHORT_DESCRIPTION, "Some short description");
}
public void actionPerformed(ActionEvent e) {
}
}
private void limpaCampos(){
txtNome.setText("");
txtEndereco.setText("");
txtNumero.setText("");
txtBairro.setText("");
txtCep.setText("");
txtComplemento.setText("");
tabelaFone.limpaTalela();
tblFone.updateUI();
txtCPF.setText("");
txtRG.setText("");
txtExp.setText("");
}
}