05-23-2012 03:16 PM
05-23-2012 03:19 PM
05-23-2012 03:33 PM
Hi Techie
Try this, if you want to customize the height and widht of EditField.
EditField e = new EditField(){
protected void layout(int w, int h)
{
super.setExtent(w, h);
super.layout(w, h);
}
};
Thanks
05-23-2012 03:51 PM
pankajace12 wrote:
Hi Techie
Try this, if you want to customize the height and widht of EditField.
EditField e = new EditField(){ protected void layout(int w, int h) { super.setExtent(w, h); super.layout(w, h); } };Thanks
This code is incorrect. first, setExtent is completely meaningless before the invocation of layout, because layout will override whatever extent is already set; second, after you remove the unnecessary setExtent, it becomes just a call to the parent class' layout with the same parameters, which is easier achieved by not overriding anything at all.
The proper way of doing it is as follows (suppose you have the maximum width you are willing to allow in a myMaxWidth variable and the height in myMaxHeight):
protected void layout(int maxWidth, int maxHeight) {
super.layout(Math.min(maxWidth, myMaxWidth), Math.min(maxHeight, myMaxHeight));
}
05-23-2012 03:57 PM
05-24-2012 04:43 AM
Thanks so much arkadyz and pankajace12
It worked.
Really appreciate your efforts in guiding me.
Is there any way to add a newline to editfield as the box is not coming in line with the editfield.
Please refer the code
HorizontalFieldManager hfm = new HorizontalFieldManager();
LabelField lbl = new LabelField("\n Name: ");
//As you can see a newline has been added to the name.As the result it goes one level down on the form.But the editfied doesnt.Is there any way to add newline to editfield like String str=" " or something
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;
}
};
TextField1.setBorder(BorderFactory.createRoundedBo rder(new XYEdges(5,5,5,5)));
hfm.add(lbl);
hfm.add(TextField1);
add(hfm);
05-24-2012 06:40 AM
Guys i have resolved my problem.Thanks again.It has taken me months in finding out an ideal way to implement.Today finally with your guidance i have done it. ![]()
Thanks a ton!!! 1m+likes for your post ![]()