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
Highlighted
New Developer
Posts: 18
Registered: ‎09-05-2013
My Device: BOLD 9900
My Carrier: VodaCom
Accepted Solution

Editfield with lines drawn on it

What I want

Please I am creating a notepad like app for my blackberry and I will like to create an editfield with lines on it like the one in the picture. I really appreciate your help.

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

Re: Editfield with lines drawn on it

New Developer
Posts: 105
Registered: ‎08-24-2013
My Device: BlackBerry Z10 | BlackBerry Dev Alpha B | BlackBerry PlayBook 32GB | BlackBerry Z10 Limited Edition
My Carrier: Not Provided

Re: Editfield with lines drawn on it

@swimming4real

Peter's post should be able to help carve that one out :-)
--
Hit Like if you appreciate this Smiley Happy
New Developer
Posts: 18
Registered: ‎09-05-2013
My Device: BOLD 9900
My Carrier: VodaCom

Re: Editfield with lines drawn on it

Please I will like the editfield to have a line drawn horizontally in order to help the user type conveniently. Thank you.
Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: Editfield with lines drawn on it

I don't understand the requirement sorry - the user does not need assistance in typing on a line - the device does that for them!

 

Do you see this sort of Field being used for any Blackberry input screens, such as for email?  Remember that users will expect your application to work like a normal BlackBerry application. 

 

PS. Forgot to say earlier, welcome to the forum.

Regular Contributor
Posts: 66
Registered: ‎08-28-2010
My Device: 9630

Re: Editfield with lines drawn on it

Hello,

 

By using below code you can draw the EditField with Horizontal line. Accpet soultion if it help for you.

 

I_name = new BasicEditField("","",36,0)
{
protected boolean keyChar(char c, int status, int time) {
if (c == Characters.ENTER) {
return true;
}
return super.keyChar(c, status, time);
}
};
I_name.setPadding(5, 5, 5, 5);
I_name.setMargin(5, 5, 5, 5);
I_name.setBorder(BorderFactory.createRoundedBorder(new XYEdges(3, 3, 3, 3), 0x0083B0D7, Border.STYLE_FILLED));
I_name.setBackground(BackgroundFactory.createSolidBackground(Color.WHITE));

 

Regards,

New Developer
Posts: 18
Registered: ‎09-05-2013
My Device: BOLD 9900
My Carrier: VodaCom

Re: Editfield with lines drawn on it

Please is it possible to have an editfield with lines drawn in it like a notebook(writing book). If so can anyone please help me out with the code?
Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: Editfield with lines drawn on it

@rakeshmjiyani - I see there is Border to the EditField - but I don't see a Horizontal Line?

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

Re: Editfield with lines drawn on it

As noted, this is not standard BB input method.

 

Here is some code to get you going, I have just written this, it is not tested or compiled.  It may not work.  But you will get the idea and I'm sure with the idea you can get it to work.

 

Update the paint method in the supplied article which was this:

 

    protected void paint(Graphics g) {
 super.paint(g);
 int prevColor = g.getColor();
 g.setColor(Color.BLACK);
 g.drawRect(0, 0, getWidth(), getHeight());  // draws border
 g.setColor(prevColor);
    }

 

to something like this:

 

    protected void paint(Graphics g) {
int lineHeight = this.getFont.getHeight();
int lines = this.getHeight() / lineHeight;
for ( int i = 0; i < lines; i++ ) {
g.drawLine(0, drawHeight, this.getWidth(), drawHeight);
drawHeight = drawHeight + this.getFont().getHeight();
}
 super.paint(g);
 int prevColor = g.getColor();
 g.setColor(Color.BLACK);
 g.drawRect(0, 0, getWidth(), getHeight());  // draws border
 g.setColor(prevColor);
    }

 

As noted, not tested, not compiled, not really production quality code, but I am sure you get the idea and can rework this to suit yourself..  Let us know how you go with it.