0

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.

CRUSADER
  • 5,486
  • 3
  • 28
  • 64
Mike D
  • 4,938
  • 6
  • 43
  • 99
  • Mike it is a bit unclear what are going to achieve. Do you want border around of EACH of the two edit fields? Also do you need the border/background of the edit fields to be changed on focus on/off? – Vit Khudenko Apr 05 '11 at 18:47
  • @Arhimed My bad. Edited for clarification. Nothing about how the fields are displayed are altered, or are trying be altered because of a focus change, or any other change. – Mike D Apr 05 '11 at 20:24
  • Sorry, it is still unclear for me. Is this true: 'you are trying to display borders around EXEditField, but it does not display the borders'? Or anything else? – Vit Khudenko Apr 05 '11 at 21:34
  • @Arhimed Yes. I am trying to display a border around each of the EXEditFields to visually separate them. – Mike D Apr 06 '11 at 13:32

2 Answers2

2

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.

Nate
  • 31,017
  • 13
  • 83
  • 207
Vit Khudenko
  • 28,288
  • 10
  • 63
  • 91
  • @Arihmed I should have you on speed dial. I think you answered every blackberry question I have out up here. – Mike D Apr 06 '11 at 18:52
  • 1
    http://meta.stackexchange.com/questions/8231/are-answers-that-just-contain-links-elsewhere-really-good-answers – Gordon Sep 06 '13 at 07:04
0

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());
    }
gkane
  • 365
  • 1
  • 7