05-25-2012 03:08 AM
I have added a Name field which is an editfield.
This is what it looks-
Name: [Editfield box to contain input]
But the cursor is just not visible/showing up in this edit box which is making it difficult to understand where exactly the user wants to type.
How to get the cursor blinking in the box.Please help.Though this may seem a minute problem,its one that cant be ignored from a developer perspective.
Hope to receive a help.
Thanks.
//Add box next to field for containing input
HorizontalFieldManager hfm = new HorizontalFieldManager();
LabelField lbl = new LabelField(" Customer Name: ");
final EditField TextField1 = new EditField()
{
protected void layout(int maxWidth, int maxHeight)
{
super.layout(Math.min(maxWidth, 300), Math.min(maxHeight, 20));
}
protected boolean keyChar(char ch, int status, int time)
{
if (CharacterUtilities.isLetter(ch) || (ch == Characters.BACKSPACE || (ch == Characters.SPACE)))
{
return super.keyChar(ch, status, time);
}
return true;
}
protected void paint(Graphics g)
{
g.clear();
g.drawRect(0,0, 50, 50);
int oldColor = g.getColor();
g.setColor(Color.WHITE);
g.fillRect(0, 0, this.getPreferredWidth(), this.getPreferredHeight());
g.setColor(oldColor);
g.drawRect(100, 100, 50, 50);
super.paint(g);
}
};
TextField1.setBorder(BorderFactory.createRoundedBo rder(new XYEdges(6,6,6,6)));
hfm.add(lbl);
hfm.add(TextField1);
add(hfm);
Solved! Go to Solution.
05-25-2012 03:14 AM
05-25-2012 03:21 AM
The paint is used to add white background color to the editfield box.Please guide how to resolve.
Regards,
Techie
05-25-2012 03:35 AM
05-25-2012 04:29 AM
Hi
I tried out using paintBackground this way.
protected void paintBackground(Graphics g)
{
g.setBackgroundColor(Color.WHITE);
g.clear();
} But no change ![]()
How else to implement.
05-25-2012 06:37 AM
05-25-2012 06:45 AM
HI,
You can use setBackground for edit field, use any rectangle image it will come..
Regards,
Lakshman K
05-25-2012 06:57 AM
05-25-2012 09:40 AM
Hi Lakshman,
I want to avoid using an image.Want to get it done through the field borders itself.Any idea.Please suggest with a coding construct.
Appreciate your help.
Thanks
05-25-2012 09:45 AM
Hi Rabiray
Yes i checked that link which is based on creating a white background for editfield.
(Though that post has gone way too long with discussions)
I still couldn't see a resolve to my problem of cursor display there.
Please guide if you have any idea.
Also request you to kindly see this link to aid a small problem that i am facing in our previous discussion.
http://supportforums.blackberry.com/t5/Java-Develo
Thanks so much.