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

Posts: 100
Registered: ‎01-13-2011
My Device: Not Specified
Accepted Solution

Border and background for EditField


I want to create a white rounded EditField, but I am using Blackberry jre 4.5 so I can not use:

myEditField..setBorder(BorderFactory.createRoundedBorder(new XYEdges(2, 2, 2, 2),  0x35586C, Border.STYLE_SOLID));


Because does not have Border or BorderFactory classes.


I tried drawing a rectangle inside paint method:

myEditField = new EditField(){
			public void paint(Graphics g) {
				int prevColor = g.getColor();
				g.setColor( 0xffffff);
				g.fillRoundRect(0, 0, getWidth(), getHeight(), 10, 10);


I look fine, but the problem is that de text inserted inside the EditField can not be seen...

Posts: 604
Registered: ‎12-27-2010
My Device: Not Specified

Re: Border and background for EditField

Call super.paint() after you do your background painting. You're covering it up with the fillRoundRect(). Alternatively, if you are just wanting a border you can use drawRoundRect().