-1
Hello, I’m having trouble dealing with an error in my program.
I have two combobox inside a registration panel. When executing already appears the list of products and customers, but the code field is not filling. I created a Popupmenuwillbecomeinvisible event on each combobox.
private void preencherCodigoClientePeloCombobox(){
modelCliente = controllerCliente.getClienteController(jcbNomeCliente.getSelectedItem().toString());
jtfCodigoCliente.setText(String.valueOf(modelCliente.getIdCliente()));
}
private void preencherCodigoProdutoPeloCombobox(){
modelProdutos = controllerProdutos.retornarProdutoController(jcbNomeProduto.getSelectedItem().toString());
jtfCodigoProduto.setText(String.valueOf(modelProdutos.getIdProduto()));
}
E o java pedi para fazer a conversão de String para inteiro, Fiz asssim:
private void preencherCodigoClientePeloCombobox(){
modelCliente = controllerCliente.getClienteController(Integer.parseInt(jcbNomeCliente.getSelectedItem().toString()));
jtfCodigoCliente.setText(String.valueOf(modelCliente.getIdCliente()));
}
private void preencherCodigoProdutoPeloCombobox(){
modelProdutos = controllerProdutos.retornarProdutoController(Integer.parseInt(jcbNomeProduto.getSelectedItem().toString()));
jtfCodigoProduto.setText(String.valueOf(modelProdutos.getIdProduto()));
}
Only it’s still wrong:
run:
Exception in thread "AWT-EventQueue-0" java.lang.NumberFormatException: For input string: "teste"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.lang.Integer.parseInt(Integer.java:580)
at java.lang.Integer.parseInt(Integer.java:615)
at view.ViewVendas.preencherCodigoClientePeloCombobox(ViewVendas.java:538)
at view.ViewVendas.<init>(ViewVendas.java:42)
at view.ViewVendas$11.run(ViewVendas.java:531)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)
at java.awt.EventQueue.access$500(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:709)
at java.awt.EventQueue$3.run(EventQueue.java:703)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:205)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
Any possible solution?
I have these methods that fill my combobox with my data.
– Vinicius Lira