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

BlackBerry® World™ Development

Reply
Contributor
Posts: 16
Registered: ‎01-22-2013
My Device: Blackberry9800
My Carrier: JAZZ

CustomEditField paint method slows down the typing speed..

Hi,i have a problem using CustomeEditField in my program..When i use CustomEditField, paint method slows down the typing speed in text box, while using EditField doesnot effect the typing speed..Plx anyone guide me for this issue..I am posting my code, where i commit CustomEditField and using simple EditField...

Thanks.

 

-----------------------------------Test Class-----------------------------------------



public class TestClass extends MainScreen implements FieldChangeListener

{
ButtonField btn;

public TestClass()
{
//CustomEditField ed ;

EditField e23d = new EditField("","");
e23d.setBorder(BorderFactory.createRoundedBorder(new XYEdges(2,5,2,5), 0xD0D0D0, Border.STYLE_SOLID));
e23d.setBackground(BackgroundFactory.createSolidBackground(Color.WHITE));

e23d.setFilter(MyTextFilter.get(TextFilter.NUMERIC));

 

//ed = new CustomEditField("");

// add(ed);

 

add(e23d);

btn = new ButtonField("");
add(btn);
btn.setChangeListener(this);
}

 

public void fieldChanged(Field field, int context) {
if (field == btn)
{
UiApplication.getUiApplication().pushScreen(new NextScreen());
}


}
}

 

----------------------------------CustomEditField------------------------------------------

 

class CustomEditField extends EditField
{
private boolean _focusableFlag;
private String defaultText;

public CustomEditField(String defaultText)
{
super(FIELD_HCENTER);
this.defaultText = defaultText;

}

public void setFocusable(boolean focusable){
_focusableFlag =focusable;
}

protected void layout(int width, int height)
{
width = Font.getDefault().derive(Font.BOLD, Font.getDefault().getHeight()-2).getAdvance("Transfer to my Linked Account")+40;
height = Font.getDefault().getHeight();
super.layout(width,height);
super.setExtent(width,height);
super.setFilter(MyTextFilter.get(TextFilter.NUMERIC));

}

protected void paint(Graphics g)
{
setBorder(BorderFactory.createRoundedBorder(new XYEdges(5,5,5,5), 0xD0D0D0, Border.STYLE_SOLID));
setBackground(BackgroundFactory.createSolidBackground(Color.WHITE));

if(super.getText().length() == 0)
{
g.setColor(0xD0D0D0);
g.drawText(defaultText, 0, 0);
}

g.setColor(0x484C54);
super.paint(g);

}



}

Developer
Posts: 153
Registered: ‎12-03-2012
My Device: PP
My Carrier: base(kpn)/BE, t-mobile/PL

Re: CustomEditField paint method slows down the typing speed..

http://supportforums.blackberry.com/t5/Java-Development/bd-p/java_dev
--
Regards,
Pawel Gorny
my apps: http://pawelgorny.com/
PGpgp, Your Reply, Anagrammatist, Texas Hold'em Odds Calculator, Contacts to CSV
If your issue has been solved, please resolve it by marking "Accept as Solution"