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

Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.

Posts: 22
Registered: ‎01-19-2009
My Device: Not Specified
Accepted Solution

How to change the size of any Field?

Hi, I'm developing a CLDC Application on JDE 4.7, and I have a problem while I create a custom Field (any field, NullField, VertivalFieldManaher, LabalField, etc). I make an override from the getPreferredWidth() or getPreferredHeight() methods to set the new height and width of my field, but when a print a string to console in the method paint, I see that this method paint is executed in a cycle.


This an expmple of code:


public class ExpanderField extends VerticalFieldManager { public int getPreferredHeight() { return 200; } public int getPreferredWidth() { return 200; } protected void subpaint(Graphics graphics) { //super.paint(graphics); System.out.println("Paint Method Executed"); } protected void sublayout(int width, int height) { super.sublayout(getPreferredWidth(), getPreferredHeight()); super.setExtent(getPreferredWidth(), getPreferredHeight()); System.out.println("layout executed..."); } }// ExpanderField class


In this example, the string "Paint Method Executed" is printed constantly. I don't know why the paint method is executed all the time.


Anybody know what's happen?

Posts: 22
Registered: ‎01-19-2009
My Device: Not Specified

Re: How to change the size of any Field?

I think that I found the answer. In other class of my project I put the sentence setPosition(); within the paint() method of a VerticalFieldManager and this sentence call the paint method again, so this make a cycle, and all the fields controlled for this VerticalFieldManager are painted again when is executed the paint method in the VerticalFieldManager.


But I have a question for the RIM Developers...




Why in the code example above, you're using the sentences setPosition(); and getManager().invalidate(); within Paint() method?, so this sentences call constantly the Paint method and don't stop never, it is not a efficient way to program an application.

Posts: 696
Registered: ‎12-02-2008
My Device: Not Specified

Re: How to change the size of any Field?



 I did'nt find any setPostion() call in the program Smiley Wink.


 And they have mentioned why they have used invalidate() just make changes in this program and notice the chnage in the behaviour.


You will be able to understand it more clearly.

Rajat Gupta.
If your problem was get solved then please mark the thread as "Accepted solution" and kudos - your wish