Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
New Contributor
bb_newb
Posts: 7
Registered: ‎07-05-2011
My Device: Playbook

UI tutorial error

Hi, I'm following the user interface tutorial here:

http://supportforums.blackberry.com/rim/attachments/rim/java_dev@tkb/11/1/User_Interface_V3.pdf

 

When I run the program in a simulator it seems to run fine until I attempt to change a capital.  When I do, I get a null pointer exception in this block of code:

 

    private MenuItem _changeCapital = new MenuItem("Change Capital", 110, 10) {
    	public void run() {
    		if (displayed == 0)
    			_canadaCapital = _input.getText();
    		else if (displayed == 1)
    			_ukCapital = _input.getText();
    		else if (displayed == 2)
    			_usCapital = _input.getText();
    	}
    };

 It seems to be _input.getText(); is returning a null value.  _input is a BasicEditField, and the field I think it references does have text in it.  Also, it successfully sets the text in other locations in the code with _input.setText().

 

My code is currently unmodified.  It's simply a cut&paste from the tutorial.  Can someone fill me in on what the problem is?

 

My only potential lead is a warning that _changeCapital is being initialized with a deprecated constructor.
  I can't see why that would matter though.  Oh yes, also _input is a different color (blue) in my IDE on the getText() lines, compared to the setText() lines (black).  I'm new to Eclipse, so I don't know what that means.

 

Thanks for any help!

Please use plain text.
New Contributor
bb_newb
Posts: 7
Registered: ‎07-05-2011
My Device: Playbook

Re: UI tutorial error

bump?
Please use plain text.
Developer
jprofitt
Posts: 604
Registered: ‎12-27-2010
My Device: Not Specified

Re: UI tutorial error

If you're using the code copied from that PDF, make sure you aren't mixing "_input" and "input" (they use "input").

Please use plain text.
New Contributor
bb_newb
Posts: 7
Registered: ‎07-05-2011
My Device: Playbook

Re: UI tutorial error

Yeah, I don't see anywhere in that tutorial where they use 'input' instead of '_input'.

Please use plain text.
Developer
jprofitt
Posts: 604
Registered: ‎12-27-2010
My Device: Not Specified

Re: UI tutorial error

Pages 11, 12, 14 (use both on this page actually), 15, and 16

Please use plain text.
New Contributor
bb_newb
Posts: 7
Registered: ‎07-05-2011
My Device: Playbook

Re: UI tutorial error

I realize you're trying to help, so want to be rude, but... are we looking at the same source?

 

On the pages you mention, I see nothing but _input variables.  For example, from various lines on page 11:


BasicEditField _input;
_input = new BasicEditField("Capital (can be changed): ", _capital);
_fieldManagerMiddle.add(_input);
_input.setText(_canadaCapital);
_input.setText(_ukCapital);

 

 Perhaps your pdf viewer isn't rendering underscores properly?

Please use plain text.
Developer
jprofitt
Posts: 604
Registered: ‎12-27-2010
My Device: Not Specified

Re: UI tutorial error

Apparently it is not rendering some of the _'s for me...interesting

Please use plain text.