views:

25

answers:

1

alt text

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 all time.

Thanks.

+2  A: 

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);
Yeti
So your saying the Blackberry doesn't actually have a usable textbox control? :S
Serg
No. It has! But if you want draw borders - you shold draw it by your code. As i know, since OS 4.6 already has BordersFactory or smth like that, but if you want bordered control in OS from 4.5 to 6.0, implement your own inherited(!) class.
Yeti
I'm targetting the new Storm models. Can you tell me how to create a nice looking textbox without overriding? My support for older models is needless.
Serg
Look at editeed answer!
Yeti