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
Trusted Contributor
Posts: 200
Registered: ‎02-22-2010
My Device: BlackBerry 9550
My Carrier: Airtel
Accepted Solution

problem with setting child fields

hi all,

        i'm using this code for jde4.7. i'm having the custom two bitmap field and i want to layout that on the other plain bitmap. in order to be simple i'm just now targetting the code to display the two bitmap using custom manager but it is showing nothing. it is displaying me blank. here is my custom manager code...

HorizontalFieldManager hfm = new HorizontalFieldManager() 
{
	public void add(Field field)
	{			
		this.add(_item1);//_item1 & _item2 is bustom bitmap field
		this.add(_item2);				
	}
	
	protected void sublayout(int maxWidth, int maxHeight)
	{	
		maxWidth =  Display.getWidth();	
		maxHeight = Display.getHeight();
		
		System.out.println("In sublayout");
		System.out.println("Max Width "+maxWidth);//360
		System.out.println("Max Height "+maxHeight);//480
		
		int count = getFieldCount();//2
		Field field;
		System.out.println("Count "+count);
		for (int i = 0; i < count; i++)
		{
		field = getField(i);						layoutChild(field,field.getWidth(),field.getHeight());
		setPositionChild(field, 50, 50);					}				
	}			
};
this.add(hfm);

 it showing me blank.

 

but when i simply add

add(_item1);

add(_item2);

it shows me the image.

 

also i want to add further that to one bimap at specific position.

 

Swapnil G.
Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: problem with setting child fields

Your manager does not define its own size. 

 

Look at the setExtent at the end of sublayout in this KB article:

How to - Create a custom layout manager for a screen
Article Number: DB-00117
http://www.blackberry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800332/800505/800508/...

 

Trusted Contributor
Posts: 200
Registered: ‎02-22-2010
My Device: BlackBerry 9550
My Carrier: Airtel

Re: problem with setting child fields

1860i9AC50C3F32C17422hi Peter,

            i understood the code but i'm now in a problem that i'm having the bitmap field on which i want to mount images on specific location. the images i would like to mount are the custombitmapbuttonfield. i am not able to overlap the bitmap on it.

 could u plz help me in which direction i should search or move?

 say in the postion 1/5/6 i want to place that "custombitmapbuttonfield"?

by the use of custommanager i'm able to arrange that custombutton button as per the alignment but not able to place on the bitmap which i have shown above?

 

Swapnil G.
Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: problem with setting child fields

Sorry, I'm not clear on what you want, and your picture is not showing.

 

Are you wanting to use an image as the background for your two custom buttons?  if so, there are other Threads in this forum that discuss how to use an image as a background - in fact I think they may even be a KB article.  If this is not what you are asking, can you please restate your questions. 

Trusted Contributor
Posts: 200
Registered: ‎02-22-2010
My Device: BlackBerry 9550
My Carrier: Airtel

Re: problem with setting child fields

1862i31B0E8B3F83137E31863iFF18189CF6446BDE1864i8B84B7E27D274D93

 

item1.png                   item1_pressed.png

 

 

 

 

 

 

BackgroundImage.png

 

these are my images. the backbground image covers the full screen which is bitmap field. the item1.png & item1_pressed.png are the custom bitmap button field. i want to place item1.png on the background image in the 1st box and like wise the other images also. on click on item1.png it changes to item1_pressed.png, that event i'm able to handle. problem is i'm not able to place the item1.png on backgroundimage in the 1st box.

for this what should i do?

i  hope you understand my problem now.

Swapnil G.
Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: problem with setting child fields

As I mentioned above, ways of using an image as a background and putting Fields over the top of this background image are discussed in a number of other Threads.  The 'trick' is that the background image is not added as a BitmapField, it is directly painted onto the screen, typically using paintBackground.  But search for other Threads that discuss this - if you can't think of search terms, then try "background image". 

Highlighted
Trusted Contributor
Posts: 200
Registered: ‎02-22-2010
My Device: BlackBerry 9550
My Carrier: Airtel

Re: problem with setting child fields

thanks peter. i searched as you said and found the solution.

Swapnil G.