BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 08-09-2005, 08:11 PM   #1 (permalink)
New Member
 
Join Date: Jun 2005
Model: 7520
Carrier: Sprint
Posts: 6
Post Thanks: 0
Thanked 0 Times in 0 Posts
Smile onFocus problem

Please Login to Remove!

Hi,
I am new the both Java and Blackberry, and am trying learn by stepping through the sample code. I am using the code from the knowledge base document, DB-00147. I tried to override the onFocus method using the following code
protected void onFocus (int direction){
int index = listField.getSelectedIndex();
blackBerryContact = (BlackBerryContact)blackBerryContacts.elementAt(in dex);
};
I am able to step through the code, and retrieve the first contact, but when I exit the method, I receive the following error Uncaught exception thrown. Null Pointer Exception. I went through the APIs trying to find what exceptions are thrown by ListField object, but I could not find any. I was hoping someone call me what is going wrong.

Thanks,
Tom
Offline  
Old 08-10-2005, 07:29 AM   #2 (permalink)
BlackBerry Extraordinaire
 
Join Date: Dec 2004
Location: in a house...
Model: lots
Carrier: Rogers
Posts: 1,148
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

I would imagine that,
Code:
blackBerryContact = (BlackBerryContact)blackBerryContacts.elementAt(index);
is returning a null. try adding something like this...
Code:
if ((BlackBerryContact)blackBerryContacts.elementAt(index)==null)
    { 
        System.err.println("Element is null");
        return;
    }
else
    {  
        blackBerryContact = (BlackBerryContact)blackBerryContacts.elementAt(index); 
    }
If you can post a little more code around what you have already posted so we can see where you are trying to override the method it may be more helpful as well.

cd.
Offline  
Old 08-10-2005, 07:30 AM   #3 (permalink)
BlackBerry Extraordinaire
 
Join Date: Dec 2004
Location: in a house...
Model: lots
Carrier: Rogers
Posts: 1,148
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Kinda weird how spaces keep getting added to the code even though they are not there when we make the post. I have noticed this before.

cd.
Offline  
Old 08-10-2005, 05:26 PM   #4 (permalink)
New Member
 
Join Date: Jun 2005
Model: 7520
Carrier: Sprint
Posts: 6
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you for responding. I tried your code, but I still got the error. I am not familiar enough with the Blackberry IDE or the Blackberry API's to do any heavy debugging. I have included the code in the attached zip file. I thought it would be easier for you to find the problem. I hope you do not mind.

Thank you very much,
Tom

Last edited by tommcf : 08-13-2005 at 02:54 PM.
Offline  
Old 08-11-2005, 08:13 PM   #5 (permalink)
New Member
 
Join Date: Jun 2005
Model: 7520
Carrier: Sprint
Posts: 6
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Please disregard my last post. I figured it out.
Thanks
Offline  
Old 08-13-2005, 12:00 PM   #6 (permalink)
New Member
 
Join Date: Aug 2005
Model: 7290
Posts: 2
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

How about sharing the solution to your problem?

Thanks
Offline  
Closed Thread


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

URBEST 50 Pcs 6mm 15/64" Shaft Dia. Nonslip Potentiometer Knobs Red Black
$9.62
URBEST 50 Pcs 6mm 15/64Mallory M Type Potentiometer 40k Ohm 4W
$8.5
Mallory M Type Potentiometer 40k Ohm 4W picture1 x Wire Wound Potentiometer TESLA WN69170 22R 2W (1pcs)
$2.0
1 x Wire Wound Potentiometer TESLA WN69170 22R 2W (1pcs) picture2PCS 2W 220Ω Multi-Turn Precision Potentiometer With 4mm Dia Shank
$4.94
2PCS 2W 220Ω Multi-Turn Precision Potentiometer With 4mm Dia Shank picture2W 10KΩ Black Precision Multi-Turn Linear Potentiometer Pack of 2
$4.94
2W 10KΩ Black Precision Multi-Turn Linear Potentiometer Pack of 2 picture






Copyright 2004-2016 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.