开发者

How can I show a textbox on my BlackBerry application?

How can I show a textbox on my BlackBerry application?

How can I add a textbox so a user can enter numeric values into my form? I need the borders of the textbox control to be visible at a开发者_StackOverflow社区ll time.

Thanks.


You should implement your own class, inherited from TextBox and override void paint(Graphics g) method.

Smth, like that, sorry i write from mobile:

public void paint(Graphics g)
{       
    // set color
    g.setColor(0x555555);
    // draw 100*100 rectangle 
    g.drawRect(0, 0, 100, 100);
    // dont forget to invoke 
    super.paint(g);
}

If you dont want use overriding, In OS 4.6+ you can use Border and BorderFactory classes (search in All Classes list).

// Each integer represents the amount of space between the box and border
// The four parameters of an XYEdge object represents each edge, 
XYEdges thickPadding = new XYEdges(10, 10, 10, 10);

// Sample text field with a thick and solid rounded border
// and single solid colour background.
RichTextField simpleField = new RichTextField("Solid rounded border, solid background");

// Create border and background objects 
Border roundedBorder = BorderFactory.createRoundedBorder(thickPadding, Border.STYLE_SOLID);

// Set the objects for use
simpleField.setBorder(roundedBorder);

// Add the field to the screen
 add(simpleField);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜