Borders Around EditFields - Blackberry

1.6k Views Asked by At

I am trying to draw a border around two text boxes, which works if I leave background colour of the main screen alone. The client's spec's call for a colour scheme with a blue background. When the EditFields are drawn to the screen, they appear as one field that spans the screen. There are 2 since each gets focus when it's supposed two and everything works otherwise. The two EditFields are then added to a GridFieldManager to control the layout.enter image description here

I am subclassing the EditFields and adding the border around each of the EXEditFields, like so:

public class EXEditField extends EditField {

    ...


    private void init( MainScreen scrn ) {
                if ( this.hasVirtualKeyboard() )
                    this.vkbd = scrn.getVirtualKeyboard();

                this.setMaxSize( this.MAX_CHARS );

                this.setBorder( BorderFactory.createRoundedBorder(new XYEdges(0,0,0,0), Border.STYLE_SOLID) );
                this.setBackground( BackgroundFactory.createSolidBackground(Color.WHITE) );
                //this.setPadding( 3, 3, 3, 3 );
                //this.setMargin( 0, 3, 0, 3 );
            }

    ...

    } // end class

Any help is greatly appreciated since there is not much in the way good Blackberry reference docs.

2

There are 2 best solutions below

2
On BEST ANSWER

Ok, check this.

It is an open source library that provides some custom BlackBerry fields, including an EditField, with custom borders. You should be able to modify the code to display the borders you want.

0
On

You might try changing the paintBackground method within your custom EditField, try putting this code into your EditField class:

    protected void paintBackground(Graphics graphics) {

        graphics.setColor(Color.BLACK);
        graphics.drawRect(0, 0, getWidth(), getHeight());

        graphics.setColor(Color.WHITE);
        graphics.fillRect(0, 0, getWidth(), getHeight());
    }