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
New Developer
Posts: 3
Registered: ‎10-28-2008
My Device: Not Specified

TextFields with Rounded Edges

Hi,

 

I've got a problem with the new decor features of OS 4.6 What I try is to get the "bubble look" for TextFields, just like RIM introduced with OS 4.5 in e.g. the mail application. Headers are in one bubble, the body has its own, etc... The iPhone look & feel... ;-)

 

Now, from reading the examples, it should go like this (starting inside a MainScreen):

       

Background backBackground = BackgroundFactory.createSolidBackground(Color.STEELBLUE);
getMainManager().setBackground(backBackground);

XYEdges padding = new XYEdges(5, 5, 5, 5);
Border roundedBorder = BorderFactory.createRoundedBorder(padding, Color.GRAY, Border.STYLE_SOLID);
Background solidBackground = BackgroundFactory.createSolidBackground(Color.WHITE);
RichTextField articleField = new RichTextField(article, RichTextField.USE_ALL_WIDTH);
articleField.setBorder(roundedBorder);
articleField.setBackground(solidBackground);
add(articleField);


Looks kind of ok, BUT: the white background in the TextField DOES NOT have rounded edges, rather, it is a plain rectangle.

What I need is a text box with rounded borders, where inside the border all is white, and outside the border all is steelblue.

 

Must be easy?!

 

Thanks for help,

Benjamin

 

New Developer
Posts: 3
Registered: ‎10-28-2008
My Device: Not Specified

Re: TextFields with Rounded Edges

Anyone? --If this is a private, hidden API (like with configuring the BIS gateway), to get a rounded white background inside a rounded border, I will also be happy to learn that. I just don't want to waste time searching for a solution. --Thanks much!

 

Developer
Posts: 16,786
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: TextFields with Rounded Edges

i think graphics.fillRoundRect is what you are looking for.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
New Developer
Posts: 4
Registered: ‎10-23-2008
My Device: Not Specified

Re: TextFields with Rounded Edges

I am also in the same position.  I have been using the BorderFactory in 4.7.0 to try and create a border and set this on a VerticalFieldManager.  Please tell me that I don't have to start messing around with graphics.fillRoundRect just to get a white rounded rectange inside a gray box (like the tasks app - screenshot below)?! Smiley Surprised

 

 

There seems to be very little point to the BorderFactory if this is case...?

New Developer
Posts: 3
Registered: ‎10-28-2008
My Device: Not Specified

Re: TextFields with Rounded Edges

Thank you. Same thoughts on my side. This must (should) just be one dedicated Java object to instantiate... Why to hack around with low level stuff for such a basic functionality.

 

I just cannot believe that RIM was doing it the low level way for all the rebrushed core applications in OS >= 4.5. So, what's the secret here?

Developer
Posts: 16,786
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: TextFields with Rounded Edges

i develop for 4.2.1+ and am used to using my own fields for nearly everything. while it is useful to carry the use&feel of native applications you can improve a lot ui-wise.
just take a look at a random successful application, chances are that it has a custom UI.
rim is slowly introducing more rich ui components but you can't really develop an application with jde 4.6+ without leaving 95% of your potential customers out in the rain.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
BlackBerry Development Advisor
Posts: 15,264
Registered: ‎07-09-2008
My Device: BlackBerry Passport
My Carrier: Bell

Re: TextFields with Rounded Edges

You can set the background colour of the manager holding the RichTextField.  This can give a rounded look to the field and allow a different background colour.
Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
New Developer
Posts: 4
Registered: ‎10-23-2008
My Device: Not Specified

Re: TextFields with Rounded Edges


MSohm wrote:
You can set the background colour of the manager holding the RichTextField.  This can give a rounded look to the field and allow a different background colour.
Unfortunately, when I set the background colour (via setBackground) of either the MainScreen subclass I am using or the VerticalFieldManager I am adding my fields to, the background colour stops at the end of the fields (i.e. when I set a grey background, there is a white area shown below my fields).
The problem is as described here: http://www.jonathanhfisher.co.uk/b2/?p=96
Managed to get rounded boxes by making my own FieldManager subclass and directly painting it.
I knew there was a reason for the lack of UI-consistency on BlackBerry devices, and these kind of problems appear to be it! 

 

New Developer
Posts: 4
Registered: ‎01-01-2009
My Device: Pearl 8220

Re: TextFields with Rounded Edges

I am not sure about anything < 4.6, I have not checked, but there is a method in BorderFactory called createBitmapBorder which takes two parameters. The first is an XYEdges object which defines the padding for the borderBasically anything that is outside of the padding and not in the corners will be repeated as the border expands, and the corners will remain the sameThe second parameter is the bitmap which will be used for the border, make sure you use a try-catch block when you load the bitmap in order handle the exception that it could possibly throw.

 

Here is some (albeit sloppy) code that wrote while I was playing around with it...

 

 

try {
container.setBorder(BorderFactory.createBitmapBorder(new XYEdges(14,14,14,14),
Bitmap.getBitmapResource("box.png")));


}
catch (IllegalArgumentException e) {
System.out.println(e.getMessage());
}

...where container is a VerticalFieldManager.

 

Here is what the border looks like...

 

 

Screenshot of border test

 

And here is the image for the border (*note: tinypic changed the file name)

 

Border image

 

What is neat about this, is that you can "skin" your application to make it look any way you wantI think this is the way they make the newer applications look the way they do.  

 

Let me know if this helps, and feel free to use the image for your borders. (Though it would be nice if you would let me know)

New Developer
Posts: 13
Registered: ‎11-24-2009
My Device: Not Specified

Re: TextFields with Rounded Edges

Very nice! After all the complaining in this thread I thought it wasn't possible with the new Border class. Works wonderfully.