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
ZevsVU
Posts: 20
Registered: ‎05-17-2012
My Device: have no device
Accepted Solution

Draw rectangle on the background of label

Please helep me add image on background of label (resizable image from size of scree)

 

i could add image but can't make it resizable and can't make it in the background(((

 

Bitmap imageBitmap = Bitmap.getBitmapResource("rectangle.png");
BitmapField bitmapField = new BitmapField(imageBitmap, BitmapField.FIELD_HCENTER);
add(bitmapField);

Please use plain text.
Developer
rabiray
Posts: 141
Registered: ‎07-13-2011
My Device: BB Bold

Re: Draw rectangle on the background of label

If you need to draw a rectangle around a label, why not creating a custom label field.

Why to use image.

Please use plain text.
Developer
rabiray
Posts: 141
Registered: ‎07-13-2011
My Device: BB Bold

Re: Draw rectangle on the background of label

Please use plain text.
Developer
arkadyz
Posts: 2,268
Registered: ‎07-08-2009
My Device: various

Re: Draw rectangle on the background of label

Do you want a border around your label (is it a LabelField)? If yes, take a look into various setBorder methods. There are available since OS 4.6.

----------------------------------------------------------
please click 'Accept Solution' on posts that provide the solution to the question you've posted. Don't say "Thanks", press 'Like' button instead!
Please use plain text.
Developer
pankajace12
Posts: 206
Registered: ‎04-30-2011
My Device: BlackBerry Z10

Re: Draw rectangle on the background of label

Hi

 

Try this code.

 

import net.rim.device.api.ui.XYEdges;
import net.rim.device.api.ui.component.LabelField;
import net.rim.device.api.ui.container.MainScreen;
import net.rim.device.api.ui.decor.BorderFactory;

public class pkj extends MainScreen{
public pkj() {
	// TODO Auto-generated constructor stub
	LabelField lbl = new LabelField("PAWAN KUMAR - PANKAJACE12....");
	lbl.setBorder(BorderFactory.createBevelBorder(new XYEdges(2,2,2,2)));
	add(lbl);
}
}

 

Thanks

Please use plain text.
Regular Contributor
techie
Posts: 77
Registered: ‎05-21-2012
My Device: 9900

Re: Draw rectangle on the background of label

Can you please tell me how can i add a rectangle next to a textfield.
Like Name: (here theres a rounded rectangle to contain a input)
Is it possible?
Please use plain text.
Developer
pankajace12
Posts: 206
Registered: ‎04-30-2011
My Device: BlackBerry Z10

Re: Draw rectangle on the background of label

[ Edited ]

HI Techie,

 

Follow this link. I have post the answer as per your exact need.

 

http://supportforums.blackberry.com/t5/Java-Development/How-to-get-this-design-in-my-application/m-p...

 

Thanks

Pawan


Please use plain text.
Regular Contributor
techie
Posts: 77
Registered: ‎05-21-2012
My Device: 9900

Re: Draw rectangle on the background of label

Please repost.I dont see any link redirection there.
Please use plain text.
Developer
pankajace12
Posts: 206
Registered: ‎04-30-2011
My Device: BlackBerry Z10

Re: Draw rectangle on the background of label

Hi

 

import net.rim.device.api.ui.XYEdges;
import net.rim.device.api.ui.component.EditField;
import net.rim.device.api.ui.component.LabelField;
import net.rim.device.api.ui.container.HorizontalFieldManager;
import net.rim.device.api.ui.container.MainScreen;
import net.rim.device.api.ui.decor.BorderFactory;

public class pkj extends MainScreen{
public pkj() {
	// TODO Auto-generated constructor stub
	HorizontalFieldManager hfm = new HorizontalFieldManager();
	
	LabelField lbl = new LabelField("Company: ");
	EditField _editField = new EditField();
	_editField.setBorder(BorderFactory.createBevelBorder(new XYEdges(2,2,2,2)));
	hfm.add(lbl);
	hfm.add(_editField);
	add(hfm);
}
}

 

 

 

Thanks

Pawan

Please use plain text.
Regular Contributor
techie
Posts: 77
Registered: ‎05-21-2012
My Device: 9900

Re: Draw rectangle on the background of label

Thanks so much.Its perfect in implementation.But theres a small problem.I dont want that editbox to span the entire width of the screen after the label.Is there any way of controlling that.
Please use plain text.