Dá o erro a seguir se ó código for
Exception in thread “main” java.lang.NumberFormatException: For input string: “”
at java.lang.NumberFormatException.forInputString(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at java.lang.Integer.valueOf(Unknown Source)
at Interface.classetela.main(classetela.java:49)
package Interface;
import java.awt.Color;
import java.awt.Font;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JInternalFrame;
import javax.swing.JLabel;
import javax.swing.JTabbedPane;
import javax.swing.JTextField;
import org.postgresql.core.Parser;
import com.sun.xml.internal.ws.policy.privateutil.PolicyUtils.Text;
import Conexao_banco.ConnectionFactory;
import DAO.CadastraClienteDAO;
import Principal.Cliente;
import sun.font.TextLabel;
import sun.java2d.Disposer;
class classetela {
static Cliente cliente = new Cliente();
static CadastraClienteDAO cDao = new CadastraClienteDAO();
private static Connection con;
public static void main (String[]args) {
final JFrame cadcli = new JFrame("CadCli");
cadcli.setBounds(20,20,600,450);
cadcli.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JLabel codigo = new JLabel("Código: ");
codigo.setBounds(35,50,80,25);
codigo.setFont(new Font("Times new Roman",Font.BOLD,20));
JTextField text_codigo = new JTextField (50) ;
text_codigo.setBounds(105,50,40,25);
//final int valorcodigo = Integer.valueOf(Integer.parseInt(text_codigo.getText()));
final int valorcodigo = Integer.valueOf(text_codigo.getText());
JLabel nome = new JLabel("Nome: ");
nome.setBounds(45,80,70,25);
nome.setFont(new Font("Times new Roman",Font.BOLD,20));
JTextField text_nome = new JTextField (40) ;
text_nome.setBounds(105,80,465,25);
JLabel dt_nasci = new JLabel("Data de Nascimento: ");
dt_nasci.setBounds(150,50,190,25);
dt_nasci.setFont(new Font("Times new Roman",Font.BOLD,20));
JTextField text_dtnas = new JTextField (40) ;
text_dtnas.setBounds(330,50,150,25);
JLabel cpf = new JLabel("CPF: ");
cpf.setBounds(57,110,90,25);
cpf.setFont(new Font("Times new Roman",Font.BOLD,20));
JTextField text_cpf = new JTextField (40) ;
text_cpf.setBounds(105,110,230,25);
JLabel doc_id = new JLabel("ID: ");
doc_id.setBounds(350,110,70,25);
doc_id.setFont(new Font("Times new Roman",Font.BOLD,20));
JTextField text_doc_id = new JTextField (40) ;
text_doc_id.setBounds(380,110,190,25);
JLabel rua = new JLabel("Rua: ");
rua.setBounds(60,140,70,25);
rua.setFont(new Font("Times new Roman",Font.BOLD,20));
JTextField text_rua = new JTextField (40) ;
text_rua.setBounds(105,140,465,25);
JLabel bairro = new JLabel("Bairro: ");
bairro.setBounds(40,170,70,25);
bairro.setFont(new Font("Times new Roman",Font.BOLD,20));
JTextField text_bairro = new JTextField (40) ;
text_bairro.setBounds(105,170,200,25);
JLabel cidade = new JLabel("Cidade: ");
cidade.setBounds(312,170,90,25);
cidade.setFont(new Font("Times new Roman",Font.BOLD,20));
JTextField text_cidade = new JTextField (40) ;
text_cidade.setBounds(380,170,190,25);
JLabel telfixo = new JLabel("Tel. Fixo: ");
telfixo.setBounds(20,200,90,25);
telfixo.setFont(new Font("Times new Roman",Font.BOLD,20));
JTextField text_telfixo = new JTextField (40) ;
text_telfixo.setBounds(105,200,190,25);
JLabel telcel = new JLabel("Tel. Cel.: ");
telcel.setBounds(300,200,90,25);
telcel.setFont(new Font("Times new Roman",Font.BOLD,20));
JTextField text_telcel = new JTextField (40) ;
text_telcel.setBounds(380,200,190,25);
JButton incluir = new JButton("Incluir");
incluir.setBounds(240,260,80,30);
incluir.addMouseListener(new MouseListener() {
public void mouseReleased(MouseEvent arg0) {
}
public void mousePressed(MouseEvent arg0) {
}
public void mouseExited(MouseEvent arg0) {
}
public void mouseEntered(MouseEvent arg0) {
}
public void mouseClicked(MouseEvent arg0) {
/*try {
con = ConnectionFactory.createConnection();
System.out.println("conexão realizada com sucesso 2");
PreparedStatement ps = con.prepareStatement("insert into pessoa (cod_cliente,nome,data_nascimento,nr_cpf,doc_id," +
" nm_rua,bairro,nm_cid,telefone_cas,telefone_cel) " +
" values (text_codigo,text_nome,text_dtnas,text_cpf,text_doc_id," +
" text_rua,text_bairro,text_cidade,text_telfix,text_telcel)");
} catch (SQLException e) {
e.printStackTrace();
}*/
try {
con = ConnectionFactory.createConnection();
String sql = "insert into pessoa (cod_cliente,nome,data_nascimento,nr_cpf,doc_id," +
" nm_rua,bairro,nm_cid,telefone_cas,telefone_cel) " +
" values (?,?,?,?,?,?,?,?,?,?)";
PreparedStatement ps = con.prepareStatement(sql);
ps.setInt(1, valorcodigo);
} catch (SQLException e) {
e.printStackTrace();
}
}
});
JButton fechar = new JButton("Fechar");
fechar.setBounds(340,260,80,30);
fechar.addMouseListener(new MouseListener() {
public void mouseClicked(MouseEvent arg0) {
cadcli.dispose();
}
public void mouseEntered(MouseEvent arg0) {
}
public void mouseExited(MouseEvent arg0) {
}
public void mousePressed(MouseEvent arg0) {
}
public void mouseReleased(MouseEvent arg0) {
}
});
cadcli.setLayout(null);
cadcli.add(codigo);
cadcli.add(text_codigo);
cadcli.add(nome);
cadcli.add(text_nome);
cadcli.add(dt_nasci);
cadcli.add(text_dtnas);
cadcli.add(cpf);
cadcli.add(text_cpf);
cadcli.add(doc_id);
cadcli.add(text_doc_id);
cadcli.add(rua);
cadcli.add(text_rua);
cadcli.add(bairro);
cadcli.add(text_bairro);
cadcli.add(cidade);
cadcli.add(text_cidade);
cadcli.add(telfixo);
cadcli.add(text_telfixo);
cadcli.add(telcel);
cadcli.add(text_telcel);
cadcli.add(incluir);
cadcli.add(fechar);
cadcli.setVisible(true);
}
}
e se eu troco de comentário dá
Exception in thread “main” java.lang.NumberFormatException: For input string: “”
at java.lang.NumberFormatException.forInputString(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at Interface.classetela.main(classetela.java:48)