I have used EditField
with some specified width and height that works good but, when I'm entering the text in EditField
I'm unable to see the text and some times when I'm clicking on that I'm getting NullPointerException
. I'm not able to understand whether the text is entered or not. Also, I cannot see the cursor in my field. If there are any mistakes please give me suggestions.
My code is:
private EditField edto;
private int tosetWidth =400 ,tosetHeight = 50;
public WelcomeScreen()
{
/* Border For EditFields */
Border bdr = BorderFactory.createRoundedBorder(new XYEdges(4, 4, 4, 4),Border.STYLE_SOLID);
edto = new EditField(){
protected void layout(int width, int height)
{
setExtent(tosetWidth, tosetHeight);
}
};
edto.setBorder(bdr);
Text not showing because of this
protected void layout(int width, int height)
{
setExtent(tosetWidth, tosetHeight);
}
just remove and try your code is working
if you want to edit field with vertical scrolling and fixed size try following
/**
* A class extending the MainScreen class, which provides default standard
* behavior for BlackBerry GUI applications.
*/
public final class MyScreen extends MainScreen
{
/**
* Creates a new MyScreen object
*/
public MyScreen()
{
// Set the displayed title of the screen
setTitle("My Edit box Example");
VerticalFieldManager vr=new VerticalFieldManager(VERTICAL_SCROLL|VERTICAL_SCROLLBAR)
{
protected void sublayout(int maxWidth, int maxHeight) {
super.sublayout(200,100);
setExtent(200, 100);
}
};
Border bdr = BorderFactory.createRoundedBorder(new XYEdges(4, 4, 4, 4),Border.STYLE_SOLID);
EditField edto = new EditField(){
public void paint(Graphics g)
{
getManager().invalidate();
super.paint(g);
}
};
vr.setBorder(bdr);
vr.add(edto);
add(vr);
}
}
you can get output as following