begin process at 2010 02 09 17:07:15
  Trouver un code source :
 
dans
 
Accueil > Forum > 

JAVA / J2EE / J2ME

 > 

Divers

 > 

Débutant(e)

 > 

Action sur un combobox et Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException


Derniers messages déposésPoser une question dans le forum ou lancer une discussion

Action sur un combobox et Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException

mercredi 18 juin 2008 à 04:16:47 | Action sur un combobox et Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException

radmanolf

salut

Bon moi j ai un gros probleme et j ai vraiment besoin de votre aide
donc j ai deux combobox dans la premiere j ai des services et dans la deuxieme j ai les debits utilisés pour ces services
il faut que quand je fixe le service "voice" dans le 1er combobox le 2eme combobox affiche seulement le débit "12.2" et devient disabled . Pour ça j ai écris un code qui a fonctionné:

private void jComboBox1ActionPerformed(java.awt.event.ActionEvent evt) {                                          
        // TODO add your handling code here:
        int modifiers;
         if (evt instanceof ActionEvent) {
              modifiers = ((ActionEvent)evt).getModifiers();
              long modsLong = modifiers & ActionEvent.MOUSE_EVENT_MASK;
              if (modsLong == MouseEvent.BUTTON1_MASK) {
               //   System.out.println(this.jComboBox1.getItemAt(this.jComboBox1.getSelectedIndex()).toString());
                  if(this.jComboBox1.getItemAt(this.jComboBox1.getSelectedIndex()).toString().equalsIgnoreCase("voice")){
                  this.jComboBox2.removeAllItems();
                  this.jComboBox2.addItem("12.2");
                  this.jComboBox2.setEnabled(false);
                  }else
                      GetServicesRate();
                 
              }
         }

mais seulement au début maintenant quand je sélectionne voice dans le combobox1 il n'affiche plus rien dans le combobox2 et l affichage devient bizare et quand j essaye de selectionner un autre service l affichage ne change pas et le combobox2 reste aussi vide.

et l'exception suivante apparait:
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
        at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:991)
        at java.lang.Double.parseDouble(Double.java:510)
        at BudgetLink_View.TestingForm.jComboBox2ActionPerformed(TestingForm.java:648)
        at BudgetLink_View.TestingForm.access$100(TestingForm.java:22)
        at BudgetLink_View.TestingForm$2.actionPerformed(TestingForm.java:143)
        at javax.swing.JComboBox.fireActionEvent(JComboBox.java:1242)
        at javax.swing.JComboBox.contentsChanged(JComboBox.java:1313)
        at javax.swing.JComboBox.intervalRemoved(JComboBox.java:1333)
        at javax.swing.AbstractListModel.fireIntervalRemoved(AbstractListModel.java:161)
        at javax.swing.DefaultComboBoxModel.removeAllElements(DefaultComboBoxModel.java:169)
        at javax.swing.JComboBox.removeAllItems(JComboBox.java:753)
        at BudgetLink_View.TestingForm.GetServicesRate(TestingForm.java:710)
        at BudgetLink_View.TestingForm.jComboBox1ActionPerformed(TestingForm.java:607)
        at BudgetLink_View.TestingForm.access$000(TestingForm.java:22)
        at BudgetLink_View.TestingForm$1.actionPerformed(TestingForm.java:134)
        at javax.swing.JComboBox.fireActionEvent(JComboBox.java:1242)
        at javax.swing.JComboBox.setSelectedItem(JComboBox.java:569)
        at javax.swing.JComboBox.setSelectedIndex(JComboBox.java:605)
        at javax.swing.plaf.basic.BasicComboPopup$Handler.mouseReleased(BasicComboPopup.java:814)
        at java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:273)
        at java.awt.Component.processMouseEvent(Component.java:6038)
        at javax.swing.JComponent.processMouseEvent(JComponent.java:3260)
        at javax.swing.plaf.basic.BasicComboPopup$1.processMouseEvent(BasicComboPopup.java:480)
        at java.awt.Component.processEvent(Component.java:5803)
        at java.awt.Container.processEvent(Container.java:2058)
        at java.awt.Component.dispatchEventImpl(Component.java:4410)
        at java.awt.Container.dispatchEventImpl(Container.java:2116)
        at java.awt.Component.dispatchEvent(Component.java:4240)
        at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4322)
        at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3986)
        at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3916)
        at java.awt.Container.dispatchEventImpl(Container.java:2102)
        at java.awt.Window.dispatchEventImpl(Window.java:2429)
        at java.awt.Component.dispatchEvent(Component.java:4240)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
        at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
        at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)

Merci pour votre aide c tres urgent!!!   

mercredi 18 juin 2008 à 10:53:04 | Re : Action sur un combobox et Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException

jojolemariole

Salut,

Merci pour la stack trace :

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
        at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:991)
        at java.lang.Double.parseDouble(Double.java:510)

        at BudgetLink_View.TestingForm.jComboBox2ActionPerformed(TestingForm.java:648)
        at BudgetLink_View.TestingForm.access$100(TestingForm.java:22)
        at BudgetLink_View.TestingForm$2.actionPerformed(TestingForm.java:143)
        at javax.swing.JComboBox.fireActionEvent(JComboBox.java:1242)
        at javax.swing.JComboBox.contentsChanged(JComboBox.java:1313)
        at javax.swing.JComboBox.intervalRemoved(JComboBox.java:1333)
        at javax.swing.AbstractListModel.fireIntervalRemoved(AbstractListModel.java:161)
        at javax.swing.DefaultComboBoxModel.removeAllElements(DefaultComboBoxModel.java:169)
        at javax.swing.JComboBox.removeAllItems(JComboBox.java:753)

        at BudgetLink_View.TestingForm.GetServicesRate(TestingForm.java:710)
        at BudgetLink_View.TestingForm.jComboBox1ActionPerformed(TestingForm.java:607)
        at BudgetLink_View.TestingForm.access$000(TestingForm.java:22)
        at BudgetLink_View.TestingForm$1.actionPerformed(TestingForm.java:134)
        at javax.swing.JComboBox.fireActionEvent(JComboBox.java:1242)
        at javax.swing.JComboBox.setSelectedItem(JComboBox.java:569)
        at javax.swing.JComboBox.setSelectedIndex(JComboBox.java:605)
        at javax.swing.plaf.basic.BasicComboPopup$Handler.mouseReleased(BasicComboPopup.java:814)
        at java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:273)
        at java.awt.Component.processMouseEvent(Component.java:6038)
        at javax.swing.JComponent.processMouseEvent(JComponent.java:3260)
        at javax.swing.plaf.basic.BasicComboPopup$1.processMouseEvent(BasicComboPopup.java:480)
        at java.awt.Component.processEvent(Component.java:5803)
        at java.awt.Container.processEvent(Container.java:2058)
        at java.awt.Component.dispatchEventImpl(Component.java:4410)
        at java.awt.Container.dispatchEventImpl(Container.java:2116)
        at java.awt.Component.dispatchEvent(Component.java:4240)
        at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4322)
        at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3986)
        at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3916)
        at java.awt.Container.dispatchEventImpl(Container.java:2102)
        at java.awt.Window.dispatchEventImpl(Window.java:2429)
        at java.awt.Component.dispatchEvent(Component.java:4240)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
        at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
        at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)

Cette pile retrace tous les appels de fonction, le dernier appel de fonction exécuté étant situé en haut de la pile, (c'est le principe d'une pile).

Je t'ai mis en violet, ce qui se passait dans les librairies Java, et en bleu ce qui se passe dans tes librairies.

D'abord on voit que tu déclenches un évènement, sans doute quand tu sélectionnes un item dans ta première comboBox. Tu passes donc par
jComboBox1ActionPerformed, ensuite tu appelles GetServicesRate. Ce qui signifie, d'après ton code que tu n'as pas sélectionné "voice". La méthode GetServicesRate appelle removeAllElements sur ton deuxième comboBox apparemment.  Et suite à ce vidage de ton deuxième combobox, on arrive dans l'écouteur : jComboBox2ActionPerformed, lequel a appelé parseDouble sur une chaîne de caractères.  Dis-nous juste quelle chaîne de caractère tu vas lire dans jComboBox2ActionPerformedet on pourra te dire ce qui cloche.


Cette discussion est classée dans : java, awt, jcombobox, at, testingform


Répondre à ce message

Sujets en rapport avec ce message

Rmi et Jnlp [ par homersimp ] Mon but est de réaliser une applet dans un fichier jnlp, qui devrait se connecter à une servlet sur serveur(avec exemple de DaytimeServer et applet.Si Probleme pour le copier coller en java [ par Frouf85 ] Bonjour bonjour...Si vous vouliez bien me venir en aide, ca serait sympa!En fait mon copier/coller ne marche pas.Voila mon code:import java.awt.datatr Probleme d'affichage d'une applet [ par juanpipo ] Voila le message d'erreur qui s'affiche:java.awt.AWTError: BoxLayout can't be shared at javax.swing.BoxLayout.checkContainer(BoxLayout.java:342) at ja BackBuffer - NullPointerException [ par Pascmar ] Bonjour, j'ai un problème avec l'utilisation d'un "backBuffer" pour améliorer le rendu d'affichage d'une application. Le lien suivant est un exemple d Pb avec une applet [ par rubo ] Salut a tous,j'ai réalisé ( enfin g participé a la realisation) une applet upload. elle est signé est tt.Mais elle ne fonctionne po g cette erreurExc pb affichage d'une image dans un JPanel [ par mallox ] Bonjour à tous,J'ai une erreur à l'execution de mon application qui affiche une image dans un JPanel. L'image s'affiche qd meme mais une erreur est le Problème avec une fonction java [ par Bouki ] Salut,g un pb avec java, je veux demander une question avec oui ou non comme unique choix g donc fe ca :int Ok = JOptionPane.showConfirmDialog(null, " problème de transmission de variable entre classe [ par kelu28 ] voila je suis en train de développer un petit logiciel qui gère des cartes d'acquisution. mon truc marchais sans interface graphique et j'ai voullu ra URGENT ! Problème événements ! PEASE ! [ par ellandebasque ] Bonjour, j'ai des exceptions qui aparaissent et je ne sais pas pourquoi, je les ai. J'explique en détail :Voici des brides de mon code :// TypesJPanel Problème d'événements [ par ellandebasque ] Bonjour,je développe une application (logique). J'ai créé des boutons, des menus. Je leur ai rattaché des événements. Le problème est que certains (le


Nos sponsors


Sondage...

CalendriCode

Février 2010
LMMJVSD
1234567
891011121314
15161718192021
22232425262728

Consulter la suite du CalendriCode

 
Développement réalisé par Nicolas SOREL (Nix) avec l'aide de : Cyril DURAND et Emmanuel (EBArtSoft), Merci à Vincent pour ses précieux conseils.
CodeS-SourceS.com© Toute reproduction même partielle est interdite sauf accord écrit du Webmaster
CodeS-SourceS.com© est une marque déposée tous droits réservés

Google Coop CodeS-SourceS Google Coop CodeS-SourceS
Temps d'éxécution de la page : 2,668 sec (4)

Nous contacter | Annoncer sur CodeS-SourceS | Mentions légales