BOA TARDE.
ESTOU COMEÇANDO A PROGRAMAR EM JAVA.
ESTOU COM UM PROBLEMA NA HORA DE INCLUIR UM PRODUTO EM UMA TELA DE REGISTRO DE VENDAS…
OCORRE ESSE ERRO java.lang.NumberFormatException: For input string: “null”
MEU CODIGO É ESSE…
AGRADEÇO QUALQUER AJUDA…
T+
private boolean verificarQuantidade()
{
try
{
if (Integer.parseInt(String.valueOf(tffQuantidadeVenda.getValue())) > 0)
{
return true;
}
}
catch (NumberFormatException ex)
{
ex.printStackTrace();
}
return false;
}
private void incluirProduto()
{
if (verificarQuantidade())
{
br.com.vendasoutro.negocio.Venda vb = new br.com.vendasoutro.negocio.Venda();
vb.setProdutos_idProduto(produtos.get(cmbProduto.getSelectedIndex()).getIdProduto());
vb.setQuantidadeVenda(Integer.parseInt(String.valueOf(tffQuantidadeVenda.getValue())));
venda.add(vb);
String produto = produtos.get(cmbProduto.getSelectedIndex()).getNomeProduto();
String quantidade = String.valueOf(tffQuantidadeVenda.getValue());
String valor = String.valueOf(produtos.get(cmbProduto.getSelectedIndex()).getValorProduto() * Integer.parseInt(quantidade));
String [] campos = new String [] { produto, quantidade, valor};
tmRegistrarVenda.addRow(campos);
total += Double.parseDouble(valor);
tffTotalVenda.setValue(total);
}
else
{
JOptionPane.showMessageDialog(this, "Quantidade Inválida!!!");
tffQuantidadeVenda.requestFocus();
}
}