Olá
tenhu uma combobox na minha janela de cadastro de frete nele tem os fretes para nota fiscal eletronica
Codigo - descrição
1 0- Por conta do emitente
2 1- Por conta do destinatário/remetente
3 2- Por conta de terceiros
4 9- Sem frete
minha ideia é q ao clicar em gravar se o usuario nao tiver selecionado nada na combo ela grava com o registri 4 - 9- Sem frete
meu código de verificação esta assim
//combobox do frete
Frete frt = (Frete) cbFrete.getSelectedItem();
if (cbFrete.getSelectedItem().equals("Selecione")) {
cbFrete.setSelectedItem("9- Sem Frete");
pst.setInt(23, frt.getFrt_cod());
} else {
pst.setInt(23, frt.getFrt_cod());
}
tentei dessa forma tb
//combobox do frete
Frete frt = (Frete) cbFrete.getSelectedItem();
if (cbFrete.getSelectedItem().equals("Selecione")) {
cbFrete.setSelectedItem(4);
pst.setInt(23, frt.getFrt_cod());
} else {
pst.setInt(23, frt.getFrt_cod());
}
ambas da esse erro
run:
Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException: java.lang.String cannot be cast to empresarial.Frete
at empresarial.JFCliente.jbSalvarActionPerformed(JFCliente.java:1292)
at empresarial.JFCliente.access$200(JFCliente.java:27)
at empresarial.JFCliente$3.actionPerformed(JFCliente.java:226)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2018)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2341)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252)
at java.awt.Component.processMouseEvent(Component.java:6505)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3321)
at java.awt.Component.processEvent(Component.java:6270)
at java.awt.Container.processEvent(Container.java:2229)
at java.awt.Component.dispatchEventImpl(Component.java:4861)
at java.awt.Container.dispatchEventImpl(Container.java:2287)
at java.awt.Component.dispatchEvent(Component.java:4687)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4492)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422)
at java.awt.Container.dispatchEventImpl(Container.java:2273)
at java.awt.Window.dispatchEventImpl(Window.java:2719)
at java.awt.Component.dispatchEvent(Component.java:4687)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:703)
at java.awt.EventQueue.access$000(EventQueue.java:102)
at java.awt.EventQueue$3.run(EventQueue.java:662)
at java.awt.EventQueue$3.run(EventQueue.java:660)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)
at java.awt.EventQueue$4.run(EventQueue.java:676)
at java.awt.EventQueue$4.run(EventQueue.java:674)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:673)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:244)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:163)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:147)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:139)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:97)
CONSTRUÍDO COM SUCESSO (tempo total: 56 segundos)
alguem sabe como eu resolvo isso?
agradeço a atenção!