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: 28
Registered: ‎08-19-2008
My Device: Not Specified

EditField with border?

Is there any way to make a border on the EditField? Thanks.

Developer
Posts: 507
Registered: ‎07-15-2008
My Device: Not Specified

Re: EditField with border?

Extend EditField and override the paint() method
----------------
if your issue solved set "Solution" mark at the relevant post
Developer
Posts: 40
Registered: ‎07-16-2008
My Device: Not Specified

Re: EditField with border?

Hi,

 

Please find the following link,

 

http://na.blackberry.com/eng/developers/resources/journals/jul_2005/creating_textbox_field.jsp

 

u will get all the code...

BlackBerry Development Advisor
Posts: 15,023
Registered: ‎07-09-2008
My Device: BlackBerry Passport

Re: EditField with border?

Version 4.6.0 of the BlackBerry API set also includes the Border class, which allows you to customize the border of a field.
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: 2
Registered: ‎11-27-2008
My Device: Not Specified

Re: EditField with border?

I am trying to accomplish this on v4.2 and am somewhat successful.  The following code gives me a field that has the border just where I want it:

BasicEditField emailField = new BasicEditField("Email Address: ", "", 100, BasicEditField.FILTER_EMAIL) { private int iRectX = getFont().getAdvance(getLabel()); private int iRectWidth = Display.getWidth() - iRectX - 4; public void paint(Graphics g) { g.setColor(0x000000); g.drawRect(iRectX, 0, iRectWidth, 16); super.paint(g); } };

However, I am hoping to add a bit more space/padding on the top and bottom, making the field a bit higher/taller.  Overriding getPreferredHeight didn't help so I tried overriding the layout method.  That made the field the size I want but now the label and cursor are gone, and I cannot see any character entries.  Here is the code:

 

BasicEditField emailField = new BasicEditField("Email Address: ", "", 100, BasicEditField.FILTER_EMAIL) { private int iRectX = getFont().getAdvance(getLabel()); private int iRectWidth = Display.getWidth() - iRectX - 4; public int getPreferredWidth() { return Display.getWidth(); } public int getPreferredHeight() { return 30; } public void layout(int width, int height) { setExtent(getPreferredWidth(), getPreferredHeight()); } public void paint(Graphics g) { g.setColor(0x000000); g.drawRect(iRectX, 0, iRectWidth, 16); super.paint(g); } };

My intent is to eventually place a background image behind this field by using a VerticalFieldManager and overriding paint.  As you probably can guess, the image is 30 pixels tall.

 

I am new to BB development, so sorry if this is a newb question.  I have been searching for a solution for hours with no luck.

 

Thanks,

--Peter

Developer
Posts: 19,612
Registered: ‎07-14-2008
My Device: Not Specified

Re: EditField with border?

Try the following.  I believe the call to super.layout is needed so that the Field knows where to draw the Label and the Input area. 


BTW, your rectangle looks odd when the text flows onto a second line, as does one of the examples - try it, you will see. 

 

BasicEditField emailField = new BasicEditField("Email Address: ", "", 100, BasicEditField.FILTER_EMAIL) { private int iRectX = getFont().getAdvance(getLabel()); private int iRectWidth = Display.getWidth() - iRectX - 4; public int getPreferredWidth() { return Display.getWidth(); } public int getPreferredHeight() { return 30; } public void layout(int width, int height) { super.layout(width, getPreferredHeight()); setExtent(width, getPreferredHeight()); } public void paint(Graphics g) { g.setColor(0x000000); g.drawRect(iRectX, 0, iRectWidth, 16); super.paint(g); } }; // ---------------------------------------------

// layout after setExtent (seems to wipe effect of setExtent) BasicEditField emailField2 = new BasicEditField("Email Address2: ", "", 100, BasicEditField.FILTER_EMAIL) { private int iRectX = getFont().getAdvance(getLabel()); private int iRectWidth = Display.getWidth() - iRectX - 4; public int getPreferredHeight() { return 30; } public void layout(int width, int height) { setExtent(width, getPreferredHeight()); super.layout(width, getPreferredHeight()); } public void paint(Graphics g) { g.setColor(0x000000); g.drawRect(iRectX, 0, iRectWidth, 16); super.paint(g); } };

 

New Developer
Posts: 2
Registered: ‎11-27-2008
My Device: Not Specified

Re: EditField with border?

That super.layout was exactly what I needed.  Thanks!

New Developer
Posts: 2
Registered: ‎09-17-2009
My Device: Storm

Re: EditField with border?

How can i calculate with two Fields? And how can get the Records from Addressbook to calculate the Birthday Dates?

 

Need Help

 

-KaloCopter-