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


Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.


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

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!

New Contributor
Posts: 7
Registered: ‎07-05-2011
My Device: Playbook
My Carrier: none

Re: UI tutorial error

bump?
Developer
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").

New Contributor
Posts: 7
Registered: ‎07-05-2011
My Device: Playbook
My Carrier: none

Re: UI tutorial error

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

Highlighted
Developer
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

New Contributor
Posts: 7
Registered: ‎07-05-2011
My Device: Playbook
My Carrier: none

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?

Developer
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