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
Posts: 24
Registered: ‎09-20-2010
My Device: 8300
My Carrier: help

problem with backgroud color.

[ Edited ]

hello friends,

                        i am facing problem when i give color at background. when my filds can add in single page non scrolable i am using follwing code.

             protected void paint(Graphics g)
	    {
	       	g.setBackgroundColor(13559791);
	    	g.clear();
	    	g.setColor(Color.BLACK);	
	    	subpaint(g);	
	    }

 above code work when i paint background.

 

                     when my page is scrolable i give color to the verticall field manager. means when i scroll the page for that i give color to the verticall field manager . my code is bellow for that.

      public static VerticalFieldManager vfm=new VerticalFieldManager()
     { // If all component not arrange in single screen than we give color to VerticalFieldManager
     	   protected void paint(Graphics g)
	   {
	          g.setBackgroundColor(13559791);
     		  g.clear();
     		  g.setColor(Color.BLACK);
     		  subpaint(g);
     	   }
      };

 above code i use when i give color to verticall fild manger.

 

i want to ask 2 questions.

1) when i use first method. at that time i cant use setTitle(lblHeader); than it is not work when i give color to backgroud page. when i use second method than it work. when i give color to vertical field manager. and than i use setTitle(lblheader) it works. what is problem whay setTitle not work when i give color to backgroud page??

2)second is suppos my screen is small 1lable, 1edit field and one button. at that time i use  that

                   vfm.add(lblHeder);// it work like setTitle

                   vfm.add(lbl);

                   vfm.add(edf);

                   vfm.add(btn);

                    add(vfm);

 and here i am give color to screen. bcz my vfm is small if i give color to vfm bello part show white. i dont want that. and problem arrise when my above code is run bold 9000 than its keybord show on screen. than my page is scrolling. at that time my screen is break.

             i want to fix my page. it fix when i give color to vfm not to screen. what shoud i do??

 help me frnds.

 thanks,

 cool_D

Trusted Contributor
Posts: 227
Registered: ‎12-16-2009
My Device: 9530,8900,9000
My Carrier: Airtel,Docomo

Re: problem with backgroud color.

U can use 2 VerticalFieldManager 1 as shown below

1)

VerticalFieldManager vfmFieldManager=new VerticalFieldManager()
        {
            protected void sublayout(int maxWidth, int maxHeight)
            {
                super.sublayout(Display.getWidth(),Display.getHeight());
                super.setExtent(Display.getWidth(),Display.getHeight());                
            }
        };

 

vfmFieldManager.setBackground(BackgroundFactory.createSolidBackground(Color.LIGHTGRAY));

 set Backgroud of 1st vertical field,

and second with Vertical_scroll Style...

2)

VerticalFieldManager vfmMiddle=new VerticalFieldManager(VERTICAL_SCROLL|VERTICAL_SCROLLBAR);

 

add all components in Second vertical field.

 

Lathiya Himanshu.

 

Lathiya Himanshu
Contributor
Posts: 24
Registered: ‎09-20-2010
My Device: 8300
My Carrier: help

Re: problem with backgroud color.

Thanks for reply me.

                    i solve problem. but i have one issue still remain. i use that code but when i use setTitle it get the color of backgroud. not seting the title. setTitle method not work.

                   help me. my code is belllow.

    VerticalFieldManager vfmFieldManager=new VerticalFieldManager()
    {
        protected void sublayout(int maxWidth, int maxHeight)
        {
            super.sublayout(Display.getWidth(),Display.getHeight());
            super.setExtent(Display.getWidth(),Display.getHeight());  
            
        }
            protected void paint(Graphics g)
	    {
	       	g.setBackgroundColor(13559791);
	    	g.clear();
	    	g.setColor(Color.BLACK);	
	    	subpaint(g);	
	    }
    };

VerticalFieldManager vfm=new VerticalFieldManager(VERTICAL_SCROLL|VERTICAL_SCROLLBAR);




constructor()
{
       setTitle(lblHeader);
     // add all componets;
       vfm.all components;
       vfmFieldManager.add(vfm);
       add(vfmFieldManager);
      
}
 

when i run that application my backgroud screen show color but problem is that my setTitle in not work. help me.

thanks,

 cool_d

Trusted Contributor
Posts: 227
Registered: ‎12-16-2009
My Device: 9530,8900,9000
My Carrier: Airtel,Docomo

Re: problem with backgroud color.

You have to subtract the height of the Titlebar in VerticalFieldmanagers height as below where count will be the height of the TitleBar set in screen.

This will solve your problem.

VerticalFieldManager vfmFieldManager=new VerticalFieldManager()
{
protected void sublayout(int maxWidth, int maxHeight)
{
super.sublayout(Display.getWidth(),Display.getHeight()-count);
super.setExtent(Display.getWidth(),Display.getHeight())-count;

}
Lathiya Himanshu
Contributor
Posts: 24
Registered: ‎09-20-2010
My Device: 8300
My Carrier: help

Re: problem with backgroud color.

i try tht. i am subtract lblHeader height  from vertical field height. but prob is that when i use in this way.

        

VerticalFieldManager vfmFieldManager=new VerticalFieldManager()
{
     protected void sublayout(int maxWidth, int maxHeight)        
     {           
      super.sublayout(Display.getWidth(),Display.getHeight()-Display.getHeight()/10);           
      super.setExtent(Display.getWidth(),Display.getHeight()-Display.getHeight()/10);                      
      }
      protected void paint(Graphics g)
      {
	       	g.setBackgroundColor(13559791);
	    	g.clear();
	    	g.setColor(Color.BLACK);	
	    	subpaint(g);	
      }
    };

VerticalFieldManager vfm=new VerticalFieldManager(VERTICAL_SCROLL|VERTICAL_SCROLLBAR);

constructor()
{
    setTitle(lblheader);
    vfm.add(all_compnets);
    vfmFieldManager.add(vfm);
    add(vfm);
}

 

               But still problem is there setTitle funcion cant show his title. and above look like show vfm with background color and bellow one heder size white line. means that line come there. so i cant see proper solution.

              main proble is that. when i add color to back ground or vertical field it the setTitle funcion not work.

         please tel me proper solution. i send all detils.

     i need that. help me friends,

 

 thanks,

 cool_D

Highlighted
Trusted Contributor
Posts: 227
Registered: ‎12-16-2009
My Device: 9530,8900,9000
My Carrier: Airtel,Docomo

Re: problem with backgroud color.

You just manually count the screen height by pointing cursor while window is open,nearly it will be 42 or 43. 

Lathiya Himanshu