Si vous tentez de le définir, si une condition particulière est remplie, l'une des deux cases à cocher sera cochée. Cependant, je continue d'obtenir une erreur nullpointerexception.NullPointerException lors de la tentative de définition d'un jcheckbox
le code est ..
//Set the flat rate or hourly billing check boxes.
if(flatRateint > 0) {
InvoiceUI.jCheckBox1.setSelected(true);
}
else {
InvoiceUI.jCheckBox2.setSelected(true);
}
L'erreur est
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException à my.freelancebillingapp.InvoiceSelectionUI.jButton1MouseClicked (InvoiceSelectionUI.java:224) à my.freelancebillingapp.InvoiceSelectionUI.access $ 100 (InvoiceSelectionUI.java:17) à my.freelancebillingapp.InvoiceSelectionUI $ 2.mouseClicked (InvoiceSelectionUI.java:86) à java.awt.AWTEventMulticaster.mouseClicked (AWTEventMulticaster.java:253) à java.awt.Component.processMouseEvent (Component.java:6266) à javax.swing.JComponent.processMouseEvent (JComponent.java:3267) à java.awt.Component.processEvent (Component.java:6028) à java.awt.Container.processEvent (Container.java:2041) à java.awt.Component.dispatchEventImpl (Component.java:4630) à java. awt.Container.dispatchEventImpl (Container.java:2099) à java.awt.Component.dispatchEvent (Component.java:4460) à java.awt.LightweightDispatcher.retargetMouseEvent (Container.java:4574) à java.awt. LightweightDispatcher.processMouseEvent (Container.java:4247) at jav a.awt.LightweightDispatcher.dispatchEvent (Container.java:4168) à java.awt.Container.dispatchEventImpl (Container.java:2085) à java.awt.Window.dispatchEventImpl (Window.java:2475) à java. awt.Component.dispatchEvent (Component.java:4460) à java.awt.EventQueue.dispatchEvent (EventQueue.java:599) à java.awt.EventDispatchThread.pumpOneEventForFilters (EventDispatchThread.java:269) à java.awt. EventDispatchThread.pumpEventsForFilter (EventDispatchThread.java:184) à java.awt.EventDispatchThread.pumpEventsForHierarchy (EventDispatchThread.java:174) à java.awt.EventDispatchThread.pumpEvents (EventDispatchThread.java:169) à java.awt.EventDispatchThread. pumpEvents (EventDispatchThread.java:161) à java.awt.EventDispatchThread.run (EventDispatchThread.java:122)
Avez-vous essayé d'imprimer un débogage pour voir ce qui est nul? Quelle ligne du code que vous avez inclus est la ligne 224? – Nate