NullPointerException em um JComboBox addItem()

3 respostas
Poneis123

Pessoal,

Já viram algo assim, eu estou tentando adicionar um objeto ao meu ComboBox com o addItem(Objeto). Executando o projeto diretamente da IDE funciona normalmente, porém quando eu executo do jar (Runnable Jar) me da um NullPointer. O que eu achei estranho é que via IDE não ocorre NullPointer. Coloquei uma validação para verificar se o JComboBox e o Objeto estão nulo e não estão e o toString do objeto está sobrescrito normalmente sem retornar null.

Segue a stack que estourou.

Exception in thread AWT-EventQueue-0 java.lang.NullPointerException

at br.com.empresa.view.ManualFileTransmitFrame$2.actionPerformed(ManualFileTransmitFrame.java:109)

at javax.swing.JComboBox.fireActionEvent(Unknown Source)

at javax.swing.JComboBox.contentsChanged(Unknown Source)

at javax.swing.AbstractListModel.fireContentsChanged(Unknown Source)

at javax.swing.DefaultComboBoxModel.setSelectedItem(Unknown Source)

at javax.swing.DefaultComboBoxModel.addElement(Unknown Source)

at javax.swing.JComboBox.addItem(Unknown Source)

at br.com.empresa.view.ManualFileTransmitFrame.populaComboRemetente(ManualFileTransmitFrame.java:474)

at br.com.empresa.view.ManualFileTransmitFrame.getJComboBoxRemetente(ManualFileTransmitFrame.java:350)

at br.com.empresa.view.ManualFileTransmitFrame.getJContentPane(ManualFileTransmitFrame.java:327)

at br.com.empresa.view.ManualFileTransmitFrame.initialize(ManualFileTransmitFrame.java:276)

at br.com.empresa.view.ManualFileTransmitFrame.showFrame(ManualFileTransmitFrame.java:263)

at br.com.empresa.business.MainFrameBO.showManualFileTransmitFrame(MainFrameBO.java:102)

at br.com.empresa.mappings.MainFrameEventMapping.showManualFileTransmitFrame(MainFrameEventMapping.java:72)

at br.com.empresa.view.MainFrame$6.actionPerformed(MainFrame.java:325)

at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)

at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)

at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)

at javax.swing.DefaultButtonModel.setPressed(Unknown Source)

at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)

at java.awt.AWTEventMulticaster.mouseReleased(Unknown Source)

at java.awt.Component.processMouseEvent(Unknown Source)

at javax.swing.JComponent.processMouseEvent(Unknown Source)

at java.awt.Component.processEvent(Unknown Source)

at java.awt.Container.processEvent(Unknown Source)

at java.awt.Component.dispatchEventImpl(Unknown Source)

at java.awt.Container.dispatchEventImpl(Unknown Source)

at java.awt.Component.dispatchEvent(Unknown Source)

at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)

at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)

at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)

at java.awt.Container.dispatchEventImpl(Unknown Source)

at java.awt.Window.dispatchEventImpl(Unknown Source)

at java.awt.Component.dispatchEvent(Unknown Source)

at java.awt.EventQueue.dispatchEventImpl(Unknown Source)

at java.awt.EventQueue.access$000(Unknown Source)

at java.awt.EventQueue$1.run(Unknown Source)

at java.awt.EventQueue$1.run(Unknown Source)

at java.security.AccessController.doPrivileged(Native Method)

at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)

at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)

at java.awt.EventQueue$2.run(Unknown Source)

at java.awt.EventQueue$2.run(Unknown Source)

at java.security.AccessController.doPrivileged(Native Method)

at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)

at java.awt.EventQueue.dispatchEvent(Unknown Source)

at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)

at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)

at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)

at java.awt.EventDispatchThread.pumpEvents(Unknown Source)

at java.awt.EventDispatchThread.pumpEvents(Unknown Source)

at java.awt.EventDispatchThread.run(Unknown Source)

3 Respostas

Leandro_M

Posta seu código aí.

gabrielhof

O ComboBox ta disparando algum listener ou algo? Porque acho que o problema é por aí.

Poneis123

Valew Galera,

Não postei o código, pois na IDE(Eclipse) estava funcionando normalmente, então não é problema de código… Descobri o erro… Eu estava utilizando uma JDK na IDE diferente da minha máquina. Na minha máquina estava o JDK 1.6.0_25 e esta versão está com BUG q causava este nullpointer. Criei um outro tópico para falar deste bug, por favor se for responder sobre isso, utilize o link: http://www.guj.com.br/java/249020-bug-jdk-160_25

Obrigado.

Abrs.

Criado 2 de agosto de 2011
Ultima resposta 3 de ago. de 2011
Respostas 3
Participantes 3