BlackBerry Forums Support Community
              

Closed Thread
 
Thread Tools
Old 08-14-2007, 05:49 AM   #1
rock_win
Knows Where the Search Button Is
 
Join Date: Aug 2007
Model: 8100
PIN: N/A
Carrier: cingular
Posts: 33
Default NullPointerException on focusing a manager

Please Login to Remove!

Hi

As per the hierarchy manager extends Field.

So, i have overriden the drawFocus and isFocusable methods.

But whenever my isFocusable returns true for that manager, i get NullPointerException , even before its true value is set. i value is set to false, then it works fine.

I'm using the CustomManager code at BB developer site and adding drawFocus to it
Offline  
Old 08-14-2007, 07:23 AM   #2
arifzaman
Thumbs Must Hurt
 
Join Date: Jun 2007
Location: Bangladesh
Model: 8800
PIN: N/A
Carrier: EDGE
Posts: 93
Question

Hi rock_win,

Is it possible to open your source code, so that we can point to your interest?

Thanks,
ARIF
Offline  
Old 08-15-2007, 01:22 AM   #3
rock_win
Knows Where the Search Button Is
 
Join Date: Aug 2007
Model: 8100
PIN: N/A
Carrier: cingular
Posts: 33
Default

Heres the code, as soon as i set _focusable to true, i get the exception
Code:
import net.rim.device.api.ui.*;
import net.rim.device.api.ui.component.*;
import net.rim.device.api.ui.container.*;
import net.rim.device.api.system.*;




class MainFrame extends Manager{
    public boolean _focusable=false;
    boolean extent1=true;
    int _width=0,_height=0;//for width and height of individual field
        int x=0,y=0;//for each field
        
    
    MainFrame(int x,int y,int _width,int _height) { 
     super(Manager.VERTICAL_SCROLL|Manager.FOCUSABLE);
     this.x=x;
     this.y=y;
     this._width=_width;
     this._height=_height;
       }
    
    public int getPreferredWidth()
    {
        return 260;
    }
    public int getPreferredHeight()
    {
        return 160;
    }
    
        public void sublayout(int width,int height)
    {
        System.out.println("width:"+width+"\t height:"+height);
        Field field;
        int noFields=getFieldCount();     
        
     
        for(int i=0;i<noFields;i++)
        {
             field=getField(i);
            setPositionChild(field,10,10+y);
        
if(field instanceof CustomRectField){
    System.out.println("Drawing RectField"+getExtent().width+"\t"+getExtent().height);
             x=((CustomRectField)field).x;
                y=((CustomRectField)field).y;
                _width=((CustomRectField)field)._width;
                _height=((CustomRectField)field)._height;
              setPositionChild(field,x,y);
        }
            layoutChild(field,_width,_height);
            //y+=30;
        }
      
   setExtent(getPreferredWidth(),getPreferredHeight());
   
    }
  public boolean isFocusable()
    {
        return _focusable;
    }
   
}
Offline  
Old 08-15-2007, 11:29 AM   #4
bemshaswing
Talking BlackBerry Encyclopedia
 
Join Date: Oct 2006
Model: 7103
Carrier: Verizon
Posts: 259
Default

This is totally a guess but the manager class might not like being constructed with Manager.FOCUSABLE while returning false (from public boolean _focusable=false; , return _focusable) via your overriding isFocusable method.
Offline  
Old 08-16-2007, 07:45 AM   #5
rock_win
Knows Where the Search Button Is
 
Join Date: Aug 2007
Model: 8100
PIN: N/A
Carrier: cingular
Posts: 33
Default

Figured out the problem, it was the problem the fields are getting added in, at the time isFocusable is called the managers are empty
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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


Analog Panel AMP VOLT Current Ammeter Voltmeter Voltage Gauge 10A 50V DH-670 DC  picture

Analog Panel AMP VOLT Current Ammeter Voltmeter Voltage Gauge 10A 50V DH-670 DC

$12.99



2PCS 22mm Voltmeter Ammeter 3 in 1 Current Voltage Hertz Meters AC60-500V 0-100A picture

2PCS 22mm Voltmeter Ammeter 3 in 1 Current Voltage Hertz Meters AC60-500V 0-100A

$11.69



AC 80-260V 0-100A LCD Digital Display Volt Watt Power Meter Voltmeter Ammeter picture

AC 80-260V 0-100A LCD Digital Display Volt Watt Power Meter Voltmeter Ammeter

$22.50



Mini Digital Voltmeter Ammeter DC 100V 10A Car LED Display Panel Amp Volt Tester picture

Mini Digital Voltmeter Ammeter DC 100V 10A Car LED Display Panel Amp Volt Tester

$10.49



LCD Digital Multimeter Voltmeter Ammeter Ohmmeter Volt AC DC Tester Leads Meter picture

LCD Digital Multimeter Voltmeter Ammeter Ohmmeter Volt AC DC Tester Leads Meter

$10.95



US Stock Analog Panel AMP Current Ammeter Meter Gauge DH-670 0-10A DC picture

US Stock Analog Panel AMP Current Ammeter Meter Gauge DH-670 0-10A DC

$13.23







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