Wyrzuca NullPointerException

0

Tworzę obiekt

Movie movie = new Movie(textOriginalTitle.getText().trim(), textTitle.getText().trim(), textDirector.getText(), textScreenplay.getText(), (String)comboGenre.getSelectedItem(), (String)comboCountry.getSelectedItem(), comboDay.getSelectedItem() + "." + comboMonth.getSelectedItem() + "." + comboYear.getSelectedItem(),  numberOfMovies+1, runtime, budget, boxOffice, (int)comboRate.getSelectedItem(), commentRate.trim(), textOfficialSite.getText().trim(), textStudio.getText(), textDescription.getText().trim(), textTag.getText(), textOtherTitle.getText(), textFilmweb.getText().trim(), textIMDB.getText().trim(), path);

i wyrzuca mi nie wiem czemu wyjątek

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
	at Add$AddMovie.actionPerformed(Add.java:458)
	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.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$500(Unknown Source)
	at java.awt.EventQueue$3.run(Unknown Source)
	at java.awt.EventQueue$3.run(Unknown Source)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
	at java.awt.EventQueue$4.run(Unknown Source)
	at java.awt.EventQueue$4.run(Unknown Source)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$JavaSecurityAccessImpl.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

Och to proste. COŚ tam jest nullem. Ale że zrobiłeś to wszystko w 1 linijce to nie wiadomo co ;)

0

Niech każda z tych metod w konstruktorze wykonuje się do jakiegoś obiektu tymczasowego, którego później przekażesz do konstruktora. Łatwiej będziesz mógł zdebugować co tam jest null'em, bo tak to się nawet nie dowiesz :)

PS: W ogóle taki konstruktor to trochę maraska jest.

1

Stwórz sobie Builder do tego obiektu. Wtedy przynajmniej będziesz wstanie w przybliżeniu zlokalizować co może być nullem.

a poza tym

user image

1 użytkowników online, w tym zalogowanych: 0, gości: 1