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
Contributor
tusharpandey
Posts: 10
Registered: ‎01-19-2013
My Device: 9900
My Carrier: blackberry

how to use Screen class in our program , because every time i am facing illegal state exception .

public final class MyScreen extends Screen
{

public MyScreen()
{
super( new manager_class(0) );
}

protected void sublayout(int width , int height )
{
setExtent ( width/2 , height/2 );
}

}

---------------------------------------------------------------------------------------------------

public class manager_class extends Manager
{
protected manager_class
(
long style){super(style);
}

int w , h ;

protected void sublayout(int width, int height)
{
w = width ;
h = height ;

//Field f = getField(0);
//layoutChild( f , w/2-w/31 , getFont().getHeight() ) ;
//setPositionChild ( f , w/31 + w/31 , w/91 + w/134 );

setExtent ( width/2 , height/2 );
}

public void paintBackground ( Graphics g )
{
g.setColor(Color.BLACK);
g.fillRect(0 , 0 , w , h ) ;
}

}

Please use plain text.
Developer
peter_strange
Posts: 19,601
Registered: ‎07-14-2008
My Device: Not Specified

Re: how to use Screen class in our program , because every time I am facing illegal state exception .

I recommend that you read this:

http://supportforums.blackberry.com/t5/Java-Development/Create-a-custom-layout-manager-for-a-screen/...

Watch these:

http://supportforums.blackberry.com/t5/Java-Development/How-to-Extend-Manager/ta-p/446749

http://supportforums.blackberry.com/t5/Java-Development/How-to-Extend-the-Screen/ta-p/446745

and wonder round the java mini site including here:

https://developer.blackberry.com/java/documentation/managers_1969899_11.html

 

You appear to have missed the point of a Manager.  It lays out (i,e, positions) its Fields and them sets the size that it requires on screen.  You have just set the Managers size using setExtent.  So none of your Fields have been laid out. 

Please use plain text.