Welcome to the Official BlackBerry® Support Community Forums. This is your resource to discuss support topics with your peers, and learn from each other. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

Java Development

Reply
Contributor
MB24
Posts: 20
Registered: 07-06-2011
My Carrier: BB Developer

Border line missing in Custom popup screen

Hi,

 

I am using blackberry 4.7 and creating a custom popup screen having a background image(border at boundary) and large text. Everything is fine but getting right border line missing. Here is my code:

 

public CustomPopup(String helpTxt) {
// TODO Auto-generated constructor stub
super(new VerticalFieldManager(VerticalFieldManager.NO_VERTICAL_SCROLL));
VerticalFieldManager vfm = new VerticalFieldManager(Manager.VERTICAL_SCROLL|Manager.VERTICAL_SCROLLBAR);
RichTextField rtf = new RichTextField(helpTxt);
vfm.add(rtf);
add(vfm);
}
protected void paint(Graphics graphics) {
// TODO Auto-generated method stub
Bitmap img = resizeBitmap(popupImg, getWidth(), getHeight());
graphics.drawBitmap(0, 0, getWidth(), getHeight(),img, 0, 0);
super.paint(graphics);
}
protected void applyTheme() {}

 

I tried a lot but not getting solution yet.

Please Help.

Please use plain text.
Contributor
GovindaraoKondala
Posts: 22
Registered: 11-09-2011
My Carrier: DOCOMO

Re: Border line missing in Custom popup screen

Jst try this 

 

class CustomPopup extends PopupScreen
	{
		Bitmap img;
		public CustomPopup(String helpTxt) {
			// TODO Auto-generated constructor stub
			super(new VerticalFieldManager(VerticalFieldManager.NO_VERTICAL_SCROLL));
			 img = Bitmap.getBitmapResource("vista-theme-red.png");
			VerticalFieldManager vfm = new VerticalFieldManager(Manager.VERTICAL_SCROLL|Manager.VERTICAL_SCROLLBAR);
			RichTextField rtf = new RichTextField(helpTxt);
			vfm.add(rtf);
			add(vfm);
			}
			protected void paint(Graphics graphics) {
			// TODO Auto-generated method stub
			
			
			graphics.drawBitmap(0, 0, img.getWidth(), img.getHeight(),img, 0, 0);
			super.paint(graphics);
			}
			protected void sublayout(int paramInt1, int paramInt2) {
				super.sublayout(img.getWidth(), img.getHeight());
				setExtent(img.getWidth(), img.getHeight());
			}
	}

 call this from any mainscreen 

 

like 

 

if(field==btn){
				   			UiApplication.getUiApplication().pushScreen(new CustomPopup("Hello good morning "));

}

 you can get out put as following 

530.jpg

Please use plain text.
Developer
peter_strange
Posts: 14,614
Registered: 07-14-2008

Re: Border line missing in Custom popup screen

Can I just say that resizing a Bitmap in paint is a significant overhead. 

 

You have this:

protected void paint(Graphics graphics) {
// TODO Auto-generated method stub
Bitmap img = resizeBitmap(popupImg, getWidth(), getHeight());

 

so everytime your screen gets painted the bitmap is resized.

 

The best way to do this is override sublayout and size it in there.  If you can't figure out how to do this, at least keep a class level Bitmap which references the resized Bitmap and only resize it when your class Bitmap does not exist or its size does not match. 

Please use plain text.