Olá pessoal, estou com um dúvida e estou meio que travado nela.
Estou trabalhando em um sw de gestão para um cliente da empresa em que trabalho, e gostaria de ajuda, dicas e ou ideias.
Eu tenho um JInternal Frame onde realiza o cadastro dos dados do cliente, dando as funções de alterar e excluir e pesquisa, Quando clico no botão pesquisa o cliente quis que seguisse um padrão que ele ja tinha no outro sistema, então eu carrego uma lista de clientes em um Jframe com um Jtable e em uma das colunas eu tenho jcheck box como as fotos que estou postando, abaixo;
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package Clientes;
import Clientes.Pesquisa.Pesquisa;
import Metadata.Session;
import SwingX.JinternalFrameStub;
import InputVerifier.ValidacaoInscricao;
import Tooltip.ClienteToolTip;
import java.awt.event.ActionEvent;
import java.text.ParseException;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;
import javax.swing.text.MaskFormatter;
public class ClienteStub extends JinternalFrameStub
{
/**
* Creates new form ClienteStub
*/
public ClienteStub()
{
initComponents();
}
public void Init()
{
this.setSize(997,486);
this.setTitle("Cadastro de Clientes");
this.setBounds(super.getVideo().width/5, super.getVideo().height/6, this.getSize().width, this.getSize().height);
this.pack();
try
{
this.setClosable(true);
this.formatCNPJ = new javax.swing.text.MaskFormatter("##.###.###/####-##");
this.formatCPF = new javax.swing.text.MaskFormatter("###.###.###-##");
this.setModel();
this.setFont();
this.setEditableAt(false);
this.jButton2.setEnabled(false);
this.jButton3.setEnabled(false);
this.jButton4.setEnabled(false);
this.jButton6.setEnabled(false);
this.toolTip= new ClienteToolTip();
this.setToolTipAt();
this.setDefaultCloseOperation(JinternalFrameStub.DISPOSE_ON_CLOSE);
}
catch (ParseException ex)
{
}
super.getUiManager();
}
private void setModel()
{
jComboBox2.setModel(comboModel.getModel());
jComboBox2.setSelectedItem("Brasil");
jTable1.setModel(tableModel.setModelo());
}
private void setInputVerifierAt()
{
jFormattedTextField1.setInputVerifier(null);
jFormattedTextField2.setInputVerifier(vCEP);
jFormattedTextField3.setInputVerifier(vTelf);
jFormattedTextField5.setInputVerifier(vTelf);
jTextField2.setInputVerifier(valCampos);
jTextField3.setInputVerifier(valCampos);
jTextField4.setInputVerifier(valCampos);
jTextField5.setInputVerifier(valCampos);
jTextField7.setInputVerifier(vEmail);
}
private void removeInputVerifierAt()
{
jFormattedTextField1.setInputVerifier(null);
jFormattedTextField2.setInputVerifier(null);
jFormattedTextField3.setInputVerifier(null);
jFormattedTextField5.setInputVerifier(null);
jTextField2.setInputVerifier(null);
jTextField3.setInputVerifier(null);
jTextField4.setInputVerifier(null);
jTextField5.setInputVerifier(null);
jTextField7.setInputVerifier(null);
}
private void setEditableAt(boolean editableAT)
{
jTextField2.setEditable(editableAT);
// jFormattedTextField1.setEditable(editableAT);
jFormattedTextField2.setEditable(editableAT);
jFormattedTextField3.setEditable(editableAT);
jFormattedTextField4.setEditable(editableAT);
jFormattedTextField5.setEditable(editableAT);
jTextField3.setEditable(editableAT);
jTextField4.setEditable(editableAT);
jTextField5.setEditable(editableAT);
jTextField6.setEditable(editableAT);
jTextField7.setEditable(editableAT);
jTextField8.setEditable(editableAT);
jTextField9.setEditable(editableAT);
jComboBox1.setEnabled(editableAT);
jComboBox2.setEnabled(editableAT);
}
private void setFont()
{
jTabbedPane1.setFont(font.jtabFont);
jTabbedPane3.setFont(font.jtabFont);
jTabbedPane3.setFont(font.jtabFont);
jPanel1.setFont(font.jpainel);
jPanel2.setFont(font.jpainel);
jPanel3.setFont(font.jpainel);
jPanel4.setFont(font.jpainel);
jPanel5.setFont(font.jpainel);
jLabel1.setFont(font.jlabel);
jLabel2.setFont(font.jlabel);
jLabel3.setFont(font.jlabel);
jLabel4.setFont(font.jlabel);
jLabel5.setFont(font.jlabel);
jLabel6.setFont(font.jlabel);
jLabel7.setFont(font.jlabel);
jLabel8.setFont(font.jlabel);
jLabel9.setFont(font.jlabel);
jLabel10.setFont(font.jlabel);
jLabel11.setFont(font.jlabel);
jLabel12.setFont(font.jlabel);
jLabel13.setFont(font.jlabel);
jLabel14.setFont(font.jlabel);
jLabel15.setFont(font.jlabel);
jTextField1.setFont(font.jtext);
jTextField2.setFont(font.jtext);
jTextField3.setFont(font.jtext);
jTextField4.setFont(font.jtext);
jTextField5.setFont(font.jtext);
jTextField6.setFont(font.jtext);
jTextField7.setFont(font.jtext);
jTextField8.setFont(font.jtext);
jTextField9.setFont(font.jtext);
jFormattedTextField1.setFont(font.jtext);
jFormattedTextField2.setFont(font.jtext);
jFormattedTextField3.setFont(font.jtext);
jFormattedTextField4.setFont(font.jtext);
jFormattedTextField5.setFont(font.jtext);
jComboBox1.setFont(font.jcombo);
jComboBox2.setFont(font.jcombo);
jButton1.setFont(font.jbutton);
jButton2.setFont(font.jbutton);
jButton3.setFont(font.jbutton);
jButton4.setFont(font.jbutton);
jButton5.setFont(font.jbutton);
jButton6.setFont(font.jbutton);
}
@Override
public void userPermition(Session s)
{
super.userPermition(s);
switch(s.parameterPermission().charAt(0)) //To change body of generated methods, choose Tools | Templates.
{
case '#':
{/** todas funções do sistema*/
jButton3.setEnabled(true);
jButton4.setEnabled(true);
}
break;
case ';':
{//não pode excuir cadastros
jButton3.setEnabled(true);
jButton4.setEnabled(false);
}
break;
case '.':
{// não pode cadastrar e excluir
jButton1.setEnabled(false);
jButton2.setEnabled(false);
jButton3.setEnabled(false);
jButton4.setEnabled(false);
}
break;
}
}
private void setCPFMask()
{
jFormattedTextField1.setInputVerifier(null);
jFormattedTextField1.setFormatterFactory(null);
jFormattedTextField1.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(formatCPF));
jFormattedTextField1.setValue("");
jFormattedTextField1.setEditable(true);
jFormattedTextField1.setInputVerifier(valInsc);
}
private void setCNPJMask()
{
jFormattedTextField1.setInputVerifier(null);
jFormattedTextField1.setFormatterFactory(null);
jFormattedTextField1.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(formatCNPJ));
jFormattedTextField1.setValue("");
jFormattedTextField1.setEditable(true);
jFormattedTextField1.setInputVerifier(valInsc);
}
private void setCliente()
{
cliente = new Cliente();
cliente.setNmCli(jTextField2.getText());
cliente.setDsTipo(inscType);
cliente.setNm_insc(jFormattedTextField1.getText());
cliente.setEndCli(jTextField3.getText());
cliente.setCaCli(jTextField4.getText());
cliente.setCpCli(jFormattedTextField2.getText());
cliente.setCo_cliente(jComboBox2.getSelectedItem().toString());
cliente.setUfCli(jTextField5.getText());
cliente.setTlCli(jFormattedTextField3.getText());
cliente.setClCli(jFormattedTextField4.getText());
cliente.setFxCli(jFormattedTextField5.getText());
cliente.setCtCli(jTextField9.getText());
cliente.setEmCli(jTextField7.getText());
cliente.setOutros(jTextField8.getText());
cliente.setRamal(jTextField6.getText());
cliente.isActive(true);
}
private void setToolTipAt()
{
jTextField1.setToolTipText(getToolTip().codTool.toString());
jTextField2.setToolTipText(getToolTip().razaoTool.toString());
jComboBox1.setToolTipText(getToolTip().inscTool.toString());
}
private void cleanFrame()
{
jTextField1.setText("");
jTextField2.setText("");
jTextField3.setText("");
jTextField4.setText("");
jTextField5.setText("");
jTextField6.setText("");
jTextField7.setText("");
jTextField8.setText("");
jTextField9.setText("");
jComboBox1.setSelectedIndex(0);
jFormattedTextField1.setText("");
jFormattedTextField1.setFormatterFactory(null);
jFormattedTextField1.setValue("");
jFormattedTextField1.setEditable(false);
jFormattedTextField1.setInputVerifier(null);
jFormattedTextField2.setText(null);
jFormattedTextField3.setText(null);
jFormattedTextField4.setText(null);
jFormattedTextField5.setText(null);
}
private void getUserPreviewData(int row,int col)
{
if(row>=0 && col>=1 && jTable1.getModel().getValueAt(row, col)!=null)
{
previewCliente=new PreviewCliente();
if(previewCliente.setDadosBusca(Integer.parseInt(jTable1.getModel().getValueAt(row, 0).toString()),jTable1.getModel().getValueAt(row, 1).toString())!=null)
{
this.cliente =new Cliente();
cliente = (Cliente) previewCliente.setDadosBusca(Integer.parseInt(jTable1.getModel().getValueAt(row, 0).toString()),jTable1.getModel().getValueAt(row, 1).toString());
this.mostraCliente(cliente);
}
}
}
public void mostraCliente(Cliente c)
{
this.setInputVerifierAt();
StringBuilder cod =new StringBuilder(c.getCdCli()+"");
this.setEditableAt(true);
this.userPermition(super.getSession());
this.jButton6.setEnabled(Boolean.valueOf("true"));
//System.err.println("we "+super.getSession()!=null);
jButton1.setEnabled(false);
jButton2.setEnabled(false);
jTextField1.setText(cod.toString());
jTextField1.setEditable(false);
jTextField2.setText(c.getNmCli());
jTextField3.setText(c.getEndCli());
jTextField4.setText(c.getCaCli());
jTextField5.setText(c.getUfCli());
jTextField6.setText(c.getRamal());
jTextField7.setText(c.getEmCli());
jTextField8.setText(c.getOutros());
jTextField9.setText(c.getCtCli());
jComboBox1.setSelectedIndex(1);
jComboBox2.setSelectedItem(c.getCo_cliente());
jComboBox1ActionPerformed(new ActionEvent(jComboBox1, c.getDsTipo(),"change"));
jFormattedTextField1.setText(c.getNm_insc());
jFormattedTextField1.setEditable(true);
jFormattedTextField1.setInputVerifier(valInsc);
jFormattedTextField2.setText(c.getCpCli());
jFormattedTextField3.setText(c.getTlCli());
jFormattedTextField4.setText(c.getClCli());
jFormattedTextField5.setText(c.getFxCli());
}
private Tooltip.ClienteToolTip getToolTip()
{
return toolTip;
}
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jTabbedPane1 = new javax.swing.JTabbedPane();
jPanel1 = new javax.swing.JPanel();
jScrollPane1 = new javax.swing.JScrollPane();
jTable1 = new javax.swing.JTable(){
@Override
public boolean isCellEditable(int row, int col)
{
return false;
}
};
jTabbedPane3 = new javax.swing.JTabbedPane();
jPanel3 = new javax.swing.JPanel();
jLabel1 = new javax.swing.JLabel();
jTextField1 = new javax.swing.JTextField();
jLabel2 = new javax.swing.JLabel();
jTextField2 = new javax.swing.JTextField();
jComboBox1 = new javax.swing.JComboBox();
jFormattedTextField1 = new javax.swing.JFormattedTextField();
jLabel3 = new javax.swing.JLabel();
jTextField3 = new javax.swing.JTextField();
jLabel4 = new javax.swing.JLabel();
jTextField4 = new javax.swing.JTextField();
jLabel5 = new javax.swing.JLabel();
jLabel6 = new javax.swing.JLabel();
jFormattedTextField2 = new javax.swing.JFormattedTextField();
jTextField5 = new javax.swing.JTextField();
jLabel7 = new javax.swing.JLabel();
jComboBox2 = new javax.swing.JComboBox();
jPanel4 = new javax.swing.JPanel();
jLabel8 = new javax.swing.JLabel();
jFormattedTextField3 = new javax.swing.JFormattedTextField();
jLabel9 = new javax.swing.JLabel();
jTextField6 = new javax.swing.JTextField();
jLabel10 = new javax.swing.JLabel();
jFormattedTextField4 = new javax.swing.JFormattedTextField();
jLabel11 = new javax.swing.JLabel();
jFormattedTextField5 = new javax.swing.JFormattedTextField();
jLabel12 = new javax.swing.JLabel();
jTextField7 = new javax.swing.JTextField();
jLabel13 = new javax.swing.JLabel();
jTextField8 = new javax.swing.JTextField();
jLabel14 = new javax.swing.JLabel();
jTextField9 = new javax.swing.JTextField();
jPanel5 = new javax.swing.JPanel();
jLabel15 = new javax.swing.JLabel();
jPanel2 = new javax.swing.JPanel();
jButton1 = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
jButton4 = new javax.swing.JButton();
jButton3 = new javax.swing.JButton();
jButton5 = new javax.swing.JButton();
jButton6 = new javax.swing.JButton();
jTabbedPane1.setFocusCycleRoot(true);
jTabbedPane1.setFocusTraversalPolicyProvider(true);
jTable1.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
{null, null, null, null},
{null, null, null, null},
{null, null, null, null},
{null, null, null, null}
},
new String [] {
"Title 1", "Title 2", "Title 3", "Title 4"
}
));
jTable1.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_ALL_COLUMNS);
jTable1.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
jTable1.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
jTable1MouseClicked(evt);
}
});
jScrollPane1.setViewportView(jTable1);
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 981, Short.MAX_VALUE)
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 234, Short.MAX_VALUE)
);
jTabbedPane1.addTab("Clientes", jPanel1);
jLabel1.setText("Codigo:");
jTextField1.setEditable(false);
jLabel2.setText("Nome:");
jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Tipo", "CPF", "CNPJ" }));
jComboBox1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jComboBox1ActionPerformed(evt);
}
});
jFormattedTextField1.setEditable(false);
jLabel3.setText("Endereço:");
jLabel4.setText("Cidade:");
jLabel5.setText("U.F:");
jLabel6.setText("CEP:");
try {
jFormattedTextField2.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("##.###-###")));
} catch (java.text.ParseException ex) {
ex.printStackTrace();
}
jFormattedTextField2.setToolTipText("");
jLabel7.setText("País:");
javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
jPanel3.setLayout(jPanel3Layout);
jPanel3Layout.setHorizontalGroup(
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addComponent(jLabel3)
.addGap(2, 2, 2)
.addComponent(jTextField3, javax.swing.GroupLayout.DEFAULT_SIZE, 265, Short.MAX_VALUE)
.addGap(6, 6, 6)
.addComponent(jLabel4)
.addGap(3, 3, 3)
.addComponent(jTextField4, javax.swing.GroupLayout.PREFERRED_SIZE, 105, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(6, 6, 6)
.addComponent(jLabel6)
.addGap(2, 2, 2)
.addComponent(jFormattedTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, 81, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel7))
.addGroup(jPanel3Layout.createSequentialGroup()
.addComponent(jLabel1)
.addGap(4, 4, 4)
.addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(11, 11, 11)
.addComponent(jLabel2)
.addGap(6, 6, 6)
.addComponent(jTextField2)))
.addGap(12, 12, 12)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addGroup(jPanel3Layout.createSequentialGroup()
.addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jFormattedTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 195, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel3Layout.createSequentialGroup()
.addComponent(jComboBox2, javax.swing.GroupLayout.PREFERRED_SIZE, 135, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel5)
.addGap(3, 3, 3)
.addComponent(jTextField5, javax.swing.GroupLayout.PREFERRED_SIZE, 94, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addContainerGap())
);
jPanel3Layout.setVerticalGroup(
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel1)
.addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel2)
.addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jFormattedTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel3)
.addComponent(jTextField3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel4)
.addComponent(jTextField4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel5)
.addComponent(jLabel6)
.addComponent(jFormattedTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jTextField5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel7)
.addComponent(jComboBox2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(18, Short.MAX_VALUE))
);
jTabbedPane3.addTab("Dados Obrigtórios", jPanel3);
jLabel8.setText("Telefone:");
try {
jFormattedTextField3.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("(##)-####-####")));
} catch (java.text.ParseException ex) {
ex.printStackTrace();
}
jLabel9.setText("Ramal:");
jLabel10.setText("Celular:");
try {
jFormattedTextField4.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("(##)-*####-####")));
} catch (java.text.ParseException ex) {
ex.printStackTrace();
}
jLabel11.setText("FAX:");
try {
jFormattedTextField5.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("(##)-####-####")));
} catch (java.text.ParseException ex) {
ex.printStackTrace();
}
jLabel12.setText("E-mail:");
jLabel13.setText("Outros:");
jLabel14.setText("Contato:");
javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
jPanel4.setLayout(jPanel4Layout);
jPanel4Layout.setHorizontalGroup(
jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel4Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addGroup(jPanel4Layout.createSequentialGroup()
.addComponent(jLabel8)
.addGap(4, 4, 4)
.addComponent(jFormattedTextField3, javax.swing.GroupLayout.PREFERRED_SIZE, 117, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel9)
.addGap(3, 3, 3)
.addComponent(jTextField6, javax.swing.GroupLayout.PREFERRED_SIZE, 59, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel10)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jFormattedTextField4, javax.swing.GroupLayout.PREFERRED_SIZE, 123, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel11)
.addGap(4, 4, 4)
.addComponent(jFormattedTextField5, javax.swing.GroupLayout.PREFERRED_SIZE, 136, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel14)
.addGap(4, 4, 4)
.addComponent(jTextField9, javax.swing.GroupLayout.PREFERRED_SIZE, 171, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel4Layout.createSequentialGroup()
.addComponent(jLabel12)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jTextField7, javax.swing.GroupLayout.PREFERRED_SIZE, 332, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel13)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jTextField8)))
.addContainerGap(25, Short.MAX_VALUE))
);
jPanel4Layout.setVerticalGroup(
jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel4Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel8)
.addComponent(jFormattedTextField3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel9)
.addComponent(jTextField6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel10)
.addComponent(jFormattedTextField4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel11)
.addComponent(jFormattedTextField5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel14)
.addComponent(jTextField9, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel12)
.addComponent(jTextField7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel13)
.addComponent(jTextField8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(28, Short.MAX_VALUE))
);
jTabbedPane3.addTab("Contato", jPanel4);
jLabel15.setText("I.E");
javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
jPanel5.setLayout(jPanel5Layout);
jPanel5Layout.setHorizontalGroup(
jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel5Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel15)
.addContainerGap(952, Short.MAX_VALUE))
);
jPanel5Layout.setVerticalGroup(
jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel5Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel15)
.addContainerGap(69, Short.MAX_VALUE))
);
jTabbedPane3.addTab("Dados NF-e", jPanel5);
jButton1.setIcon(jb1Img);
jButton1.setText("Novo");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
jButton2.setIcon(jb2Img);
jButton2.setText("Salvar");
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});
jButton4.setIcon(jb4Img);
jButton4.setText("Excluir");
jButton4.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton4ActionPerformed(evt);
}
});
jButton3.setIcon(jb3Img);
jButton3.setText("Alterar");
jButton3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton3ActionPerformed(evt);
}
});
jButton5.setIcon(jb5Img);
jButton5.setText("Pesquisar");
jButton5.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton5ActionPerformed(evt);
}
});
jButton6.setIcon(jb6Img);
jButton6.setText("Cancelar");
jButton6.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton6ActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
jPanel2.setLayout(jPanel2Layout);
jPanel2Layout.setHorizontalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addGap(23, 23, 23)
.addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 103, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 103, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 103, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(jButton4, javax.swing.GroupLayout.PREFERRED_SIZE, 103, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(jButton6, javax.swing.GroupLayout.PREFERRED_SIZE, 103, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(jButton5, javax.swing.GroupLayout.PREFERRED_SIZE, 147, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
jPanel2Layout.setVerticalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButton4, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButton5, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButton6, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap())
);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jTabbedPane1)
.addComponent(jTabbedPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
.addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 261, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jTabbedPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 123, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
pack();
}// </editor-fold>
private void jComboBox1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
if(evt.getSource()==jComboBox1)
{
jFormattedTextField1.setEditable(false);
switch(jComboBox1.getSelectedIndex())
{
case 1:
inscType=1;
valInsc.insctype(inscType);
ValidacaoInscricao.setinscType(inscType);
setCPFMask();
break;
case 2:
inscType=2;
valInsc.insctype(inscType);
ValidacaoInscricao.setinscType(inscType);
setCNPJMask();
break;
case 0:
inscType=0;
valInsc.insctype(inscType);
ValidacaoInscricao.setinscType(inscType);
jFormattedTextField1.setFormatterFactory(null);
jFormattedTextField1.setValue("");
jFormattedTextField1.setEditable(false);
jFormattedTextField1.setInputVerifier(null);
break;
}
}
}
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
if(evt.getSource()==jButton1)
{
this.setEditableAt(Boolean.valueOf("true"));
this.jButton2.setEnabled(Boolean.valueOf("true"));
this.jButton6.setEnabled(Boolean.valueOf("true"));
}
}
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
if(evt.getSource()==jButton2)
{
this.setEditableAt(Boolean.valueOf("false"));
this.setInputVerifierAt();
this.setCliente();
clienteFacede = new ClienteFacede();
this.removeInputVerifierAt();
boolean blob= clienteFacede.cadastraCliente(cliente.getDsTipo(), cliente);
this.jButton2.setEnabled(Boolean.valueOf("false"));
if(blob==true)
{
cleanFrame();
JOptionPane.showMessageDialog(null, "Novo cliente cadastrado com sucesso");
this.jButton2.setEnabled(Boolean.valueOf("false"));
this.setEditableAt(Boolean.valueOf("false"));
}
else if(blob==false)
{
JOptionPane.showMessageDialog(null, "Não foi possivel realizar o cadastrado com sucesso \n verifique se os campos estão preenchidos corretamente! (Error(30))");
}
jTable1.setModel(new DefaultTableModel());
jTable1.setModel(tableModel.setModelo());
}
}
private void jTable1MouseClicked(java.awt.event.MouseEvent evt) {
// TODO add your handling code here:
if(evt.getSource()==jTable1)
{
if(evt.getClickCount()==1)
{
this.getUserPreviewData(this.jTable1.getSelectedRow(), this.jTable1.getSelectedColumn());
}
}
}
private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
if(evt.getSource()==jButton4)
{
this.setEditableAt(false);
this.removeInputVerifierAt();
clienteFacede =new ClienteFacede();
this.setCliente();
int cd_cli= Integer.parseInt(jTextField1.getText());
this.cliente.setCdCli(cd_cli);
boolean blob=this.clienteFacede.removeCliente(cliente.getDsTipo(), cliente);
int b =blob ? 1:0;
switch(b)
{
case 1:
cleanFrame();
JOptionPane.showMessageDialog(rootPane, "O cliente: "+cliente.getNmCli()+"\nfoi removido com sucesso!","Info",JOptionPane.INFORMATION_MESSAGE);
this.jButton1.setEnabled(true);
this.jButton2.setEnabled(Boolean.valueOf("false"));
this.jButton3.setEnabled(false);
this.jButton4.setEnabled(false);
this.setEditableAt(Boolean.valueOf("false"));
break;
case 0:
JOptionPane.showMessageDialog(rootPane, "Não foi excluir o cliente \n verifique se os campos estão preenchidos corretamente! (Error(35))");
break;
}
jTable1.setModel(new DefaultTableModel());
jTable1.setModel(tableModel.setModelo());
}
}
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
if(evt.getSource()==jButton3)
{
this.setEditableAt(false);
this.removeInputVerifierAt();
clienteFacede =new ClienteFacede();
this.setCliente();
int cd_cli= Integer.parseInt(jTextField1.getText());
this.cliente.setCdCli(cd_cli);
boolean blob=this.clienteFacede.alteraCliente(cliente.getDsTipo(), cliente);
int b =blob ? 1:0;
switch(b)
{
case 1:
cleanFrame();
JOptionPane.showMessageDialog(rootPane, "Dados do cliente: "+cliente.getNmCli()+"\nalteradoros com sucesso!","Info",JOptionPane.INFORMATION_MESSAGE);
this.jButton1.setEnabled(true);
this.jButton2.setEnabled(Boolean.valueOf("false"));
this.jButton3.setEnabled(false);
this.jButton4.setEnabled(false);
this.setEditableAt(Boolean.valueOf("false"));
break;
case 0:
JOptionPane.showMessageDialog(rootPane, "Não foi possivel alterar o cadastrado com sucesso \n verifique se os campos estão preenchidos corretamente! (Error(33))");
break;
}
jTable1.setModel(new DefaultTableModel());
jTable1.setModel(tableModel.setModelo());
}
}
private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
this.pesuisaCliente = new Pesquisa(new JFrame(), false);
if(this.pesuisaCliente instanceof Pesquisa)
{
this.pesuisaCliente.setVisible(true);
}
}
private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
if(jButton6==evt.getSource())
{
this.setEditableAt(false);
this.userPermition(super.getSession());
this.removeInputVerifierAt();
this.cleanFrame();
jButton2.setEnabled(false);
jButton3.setEnabled(false);
jButton4.setEnabled(false);
jButton1.setEnabled(true);
this.jButton6.setEnabled(Boolean.valueOf("false"));
}
}
// Variables declaration - do not modify
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JButton jButton3;
private javax.swing.JButton jButton4;
private javax.swing.JButton jButton5;
private javax.swing.JButton jButton6;
private javax.swing.JComboBox jComboBox1;
private javax.swing.JComboBox jComboBox2;
private javax.swing.JFormattedTextField jFormattedTextField1;
private javax.swing.JFormattedTextField jFormattedTextField2;
private javax.swing.JFormattedTextField jFormattedTextField3;
private javax.swing.JFormattedTextField jFormattedTextField4;
private javax.swing.JFormattedTextField jFormattedTextField5;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel10;
private javax.swing.JLabel jLabel11;
private javax.swing.JLabel jLabel12;
private javax.swing.JLabel jLabel13;
private javax.swing.JLabel jLabel14;
private javax.swing.JLabel jLabel15;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel8;
private javax.swing.JLabel jLabel9;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JPanel jPanel3;
private javax.swing.JPanel jPanel4;
private javax.swing.JPanel jPanel5;
private javax.swing.JScrollPane jScrollPane1;
protected javax.swing.JTabbedPane jTabbedPane1;
private javax.swing.JTabbedPane jTabbedPane3;
private javax.swing.JTable jTable1;
private javax.swing.JTextField jTextField1;
private javax.swing.JTextField jTextField2;
private javax.swing.JTextField jTextField3;
private javax.swing.JTextField jTextField4;
private javax.swing.JTextField jTextField5;
private javax.swing.JTextField jTextField6;
private javax.swing.JTextField jTextField7;
private javax.swing.JTextField jTextField8;
private javax.swing.JTextField jTextField9;
// End of variables declaration
private MaskFormatter formatCNPJ=null;
private MaskFormatter formatCPF=null;
private Pesquisa pesuisaCliente=null;
private PreviewCliente previewCliente=null;
private Cliente cliente=null;
private ClienteFacede clienteFacede=null;
private ImageIcon jb1Img = new ImageIcon(getClass().getResource("/icons/add.png"));
private ImageIcon jb2Img = new ImageIcon(getClass().getResource("/icons/save.png"));
private ImageIcon jb3Img = new ImageIcon(getClass().getResource("/icons/edit.png"));
private ImageIcon jb4Img = new ImageIcon(getClass().getResource("/icons/delete.png"));
private ImageIcon jb5Img = new ImageIcon(getClass().getResource("/icons/search.png"));
private ImageIcon jb6Img = new ImageIcon(getClass().getResource("/icons/cancel.png"));
private Tooltip.ClienteToolTip toolTip=null;
private static int inscType=0;
}
Meu frame Pesquisa
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package Clientes.Pesquisa;
import SwingX.JDialogStub;
import TableModel.ClienteTableModel;
import java.awt.Component;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import javax.swing.AbstractButton;
import javax.swing.JCheckBox;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.JTableHeader;
import javax.swing.table.TableCellRenderer;
import javax.swing.table.TableColumn;
import javax.swing.table.TableColumnModel;
/**
*
* @author pedro
*/
public class Pesquisa extends JDialogStub {
/**
* Creates new form Pesquisa
*/
public Pesquisa(java.awt.Frame parent, boolean modal) {
super(parent, modal);
initComponents();
super.setVideoFilho();
//774,531
this.setDefaultCloseOperation(JDialogStub.HIDE_ON_CLOSE);
clienteTableModel=new ClienteTableModel();
jTable1.removeRowSelectionInterval(0, 0);
DefaultTableModel modelo =clienteTableModel.getModeloPesquisa(jTable1.getModel());
jTable1.setModel(new DefaultTableModel());
jTable1.setModel(modelo);
this.setWidthTable();
TableColumn tc = jTable1.getColumnModel().getColumn(0);
tc.setCellEditor(jTable1.getDefaultEditor(Boolean.class));
tc.setCellRenderer(jTable1.getDefaultRenderer(Boolean.class));
tc.setHeaderRenderer(new Pesquisa.CheckBoxHeader(new Pesquisa.MyItemListener()));
tc.sizeWidthToFit();
this.setFont();
this.setResizable(false);
}
private void setFont()
{
jTable1.setFont(font.jtabFont);
jPanel1.setFont(font.jpainel);
jButton1.setFont(font.jbutton);
}
private void setWidthTable()
{
jTable1.getColumnModel().getColumn(0).setPreferredWidth(1);
jTable1.getColumnModel().getColumn(1).setPreferredWidth(100);
jTable1.getColumnModel().getColumn(2).setPreferredWidth(50);
jTable1.getColumnModel().getColumn(3).setPreferredWidth(50);
jTable1.getColumnModel().getColumn(5).setPreferredWidth(8);
}
public void carregarCliente()
{
for(int i=0;jTable1.getSelectedRows().length>i;i++)
{
System.err.println(jTable1.getValueAt(i, 0)+" 669 "+i);
}
}
private class MyItemListener implements ItemListener
{
@Override
public void itemStateChanged(ItemEvent e) {
Object source = e.getSource();
if (source instanceof AbstractButton == false)
{
return;
}
boolean checked = e.getStateChange() == ItemEvent.SELECTED;
for(int x = 0, y = jTable1.getRowCount(); x < y; x++)
{
jTable1.setValueAt(new Boolean(checked),x,0);
}
}
};
private class CheckBoxHeader extends JCheckBox implements TableCellRenderer, MouseListener {
protected Pesquisa.CheckBoxHeader rendererComponent;
protected int column;
protected boolean mousePressed = false;
public CheckBoxHeader(ItemListener itemListener) {
rendererComponent = this;
rendererComponent.addItemListener(itemListener);
}
@Override
public Component getTableCellRendererComponent(
JTable table, Object value,
boolean isSelected, boolean hasFocus, int row, int column) {
if (table != null) {
JTableHeader header = table.getTableHeader();
if (header != null) {
rendererComponent.setForeground(header.getForeground());
rendererComponent.setBackground(header.getBackground());
rendererComponent.setFont(header.getFont());
header.addMouseListener(rendererComponent);
}
}
setColumn(column);
rendererComponent.setText("");
//setBorder(UIManager.getBorder("TableHeader.cellBorder"));
return rendererComponent;
}
protected void setColumn(int column) {
this.column = column;
}
public int getColumn()
{
return column;
}
protected void handleClickEvent(MouseEvent e)
{
if (mousePressed)
{
mousePressed=false;
JTableHeader header = (JTableHeader)(e.getSource());
JTable tableView = header.getTable();
TableColumnModel columnModel = tableView.getColumnModel();
int viewColumn = columnModel.getColumnIndexAtX(e.getX());
int col = tableView.convertColumnIndexToModel(viewColumn);
if (viewColumn == this.column && e.getClickCount() == 1 && col != -1)
{
doClick();
}
}
}
@Override
public void mouseClicked(MouseEvent e)
{
handleClickEvent(e);
// ((JTableHeader)e.getSource()).repaint();
}
@Override
public void mousePressed(MouseEvent e) {
mousePressed = true;
}
@Override
public void mouseReleased(MouseEvent e) {
}
@Override
public void mouseEntered(MouseEvent e) {
}
@Override
public void mouseExited(MouseEvent e) {
}
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jPanel1 = new javax.swing.JPanel();
jScrollPane1 = new javax.swing.JScrollPane();
jTable1 = new javax.swing.JTable(){
@Override
public boolean isCellEditable(int row, int col)
{
if(col!=0)
{
return false;
}
else
{
return true;
}
}
};
jButton1 = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
jTable1.setModel(new javax.swing.table.DefaultTableModel
(
new Object [][] {
{new Boolean(false),null,null,null,null,null,null,null}
},
new Object[] {
"","Nome","CNPJ/CPF","Endereço","Cidade","UF","Telefone","Contato"
}
)
{
@Override
public Class getColumnClass(int column)
{
Class klass = String.class; // para todas as outras colunas use String
// primeira coluna deve ser marcável
if (column == 0)
{
klass = Boolean.class;
}
return klass;
}
}
);
jTable1.setColumnSelectionAllowed(true);
jTable1.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
jScrollPane1.setViewportView(jTable1);
jButton1.setText("Carregar");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 849, Short.MAX_VALUE)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jButton1)
.addGap(0, 0, Short.MAX_VALUE)))
.addContainerGap())
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 394, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jButton1)
.addContainerGap())
);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
);
pack();
}// </editor-fold>
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
/**
* @param args the command line arguments
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(Pesquisa.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(Pesquisa.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(Pesquisa.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(Pesquisa.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the dialog /
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
Pesquisa dialog = new Pesquisa(new javax.swing.JFrame(), true);
dialog.addWindowListener(new java.awt.event.WindowAdapter() {
@Override
public void windowClosing(java.awt.event.WindowEvent e) {
}
});
dialog.setVisible(true);
}
});
}*/
// Variables declaration - do not modify
public transient javax.swing.JButton jButton1;
private javax.swing.JPanel jPanel1;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JTable jTable1;
// End of variables declaration
private ClienteTableModel clienteTableModel=null;// new ClienteTableModel();
}
So uma última dúvida, existe algum tipo de evento para formatar um jformattedTextField de forma generica para os diversos formatos de I.E existentes no Brasil?
Abs