You are not logged in.

#1 2010-12-03 18:13:34

bgalakazam
Arch Linux f@h Team Member
From: California, USA
Registered: 2008-09-01
Posts: 76

Java reflection - null pointer

Well this is a long shot, but I hopefully someone here can help. The goal is to use Introspection and Reflection. In short, the program creates a JFrame, left side is another JFrame and it displays an object, Rect, Circ or Ticker. Rigth side has a dropdown menu where you select which object is displayed. Under it (still right side) there are 2 more JFrames. One with the property names and the other with the property values of whatever is displayed (rect, circ or ticket). See picture below.

22222222xx.png

When an item in a text field is changed, it is supposed to redraw the object. However, I get null pointer exception. See here. Lines 336 and 183 are problematic, but I can't see why.

The following classes are present: Rect, Circ, Ticker, RectBeanInfo, CircBeanInfo, TickerBeanInfo, JFrameExt (the testing class).

I've tried to rename the jtfActionPerformed to just a general actionPerfomed, didn't help.

Click here for JFrameExt.

Rect, Circ and Ticker are identical so I will only include one of them in case you need.

Click here for Rect.

Click here for RectBeanInfo.

This is the last part that I need to fix, the reflection of the changes. Please advise if you can in any way.

Offline

#2 2010-12-07 11:52:42

shpelda
Member
Registered: 2008-08-07
Posts: 59

Re: Java reflection - null pointer

Form a quick glimpse it seems that  your "targetBeanObject" is null in method.invoke. Which leads me to that Beans.instantiate returned null.

Offline

Board footer

Powered by FluxBB