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
Developer
Posts: 435
Registered: ‎09-20-2011
My Device: Z10 LE, Playbook, DevAlpha C, 9900, 9380
My Carrier: Vodafone
Accepted Solution

Not able to see the fields inside a custom VFM

[ Edited ]

Hi all,

 

I am not able to see the Fields inside a customized VFM. 

 

Below is my code for Customized VFM:

public class CustomContentContainer extends VerticalFieldManager{
	
	String content_header;
	int container_height;
	int displayWidth = Display.getWidth();
	int displayHeight = Display.getHeight();
	
	public CustomContentContainer(String content_header,int height){
		super(Manager.NO_VERTICAL_SCROLL | Manager.NO_HORIZONTAL_SCROLL);
		this.content_header = content_header;
		container_height = displayHeight-height;
	}
	
	protected void sublayout(int maxWidth, int maxHeight) {
		super.sublayout(maxWidth, container_height);
		setExtent(maxWidth,container_height);
	};
	
	
	protected void paint(Graphics graphics) 
	{
		int X_POS = 20;
		int Y_POS = 20;
		
		int width = displayWidth;
        int height=container_height;
        int[] xPts = {0, width, width, 0};
        int[] yPts = {0, 0, height, height};
        int[] colors = { 0xffffff, 0xf7f7f6, 0xd4d0cc, 0xb0a9a2 };
        graphics.drawShadedFilledPath(xPts, yPts, null, colors, null);
        
        graphics.setColor(0xc0c0c0);
		graphics.drawRoundRect(X_POS, Y_POS, getWidth()-40, container_height-40, 10,10);
		
		int stringWidth = getFont().getAdvance(content_header);
		graphics.setColor(0xF8F8F8);
		
		graphics.fillRect(35, 5, stringWidth+10, 30);

		graphics.setColor(0xFF0000);
		graphics.drawText(content_header, 40, 5);
	};

}

Below is the  Code inside the main screen class

settingsContainer = new CustomContentContainer("Settings",vodavaultLogo.getHeight());
    	contentContainer = new VerticalFieldManager(Manager.VERTICAL_SCROLL|USE_ALL_WIDTH);
    	
    	
    	passwd1 = new CustomEditField();
    	passwd2 = new CustomEditField();
    	contentContainer.add(passwd1);
    	contentContainer.add(passwd2);
    	contentContainer.setMargin(35,35,35,35);
    	
    	mainContainer.add(vodavaultLogoField);
    	settingsContainer.add(contentContainer);
    	mainContainer.add(settingsContainer);
    	add(mainContainer);

 

 

Developer
Posts: 354
Registered: ‎06-05-2013
My Device: Blackberry Z10
My Carrier: Vodafone

Re: Not able to see the fields inside a custom VFM

you are not adding settingsContainer any where in your code
Developer
Posts: 435
Registered: ‎09-20-2011
My Device: Z10 LE, Playbook, DevAlpha C, 9900, 9380
My Carrier: Vodafone

Re: Not able to see the fields inside a custom VFM

I have re-edited the previous mesage
Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: Not able to see the fields inside a custom VFM

[ Edited ]

You need to call super.paint(..) in your VFM paint(...), if you wish it to paint any of the Fields that are added to it.

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

Re: Not able to see the fields inside a custom VFM

There are a few things that I don't think are 'correct' or best practice in the CustomContentContainer code that you have posted.  But I think it would be best if I understood what you were trying to achieve before I suggested changes.  Can you summarise how you expect to use this VFM?

Developer
Posts: 435
Registered: ‎09-20-2011
My Device: Z10 LE, Playbook, DevAlpha C, 9900, 9380
My Carrier: Vodafone

Re: Not able to see the fields inside a custom VFM

Oh right, i missed that code. Thanks Peter.