0

I'm trying to create a custom dialog for blackberry...

public class cusDialog extends Screen implements FieldChangeListener {

    private cusButtField okButton;

    protected void paintBackground(Graphics graphics) {   /// this doesn't seem to work.
        graphics.setColor(0x999966);                       /// should I somehow call it?
        graphics.fillRoundRect(0, 0, getWidth(), getHeight(), 12, 12);
        graphics.setColor(Color.BLACK);
        graphics.drawRoundRect(0, 0, getWidth(), getHeight(), 12, 12);
        }

    public cusDialog(String message) {
        super(new VerticalFieldManager(), Screen.DEFAULT_CLOSE);
        try {
        FontFamily alphaSansFamily = FontFamily.forName("BBAlpha Serif");
        Font appFont = alphaSansFamily.getFont(Font.PLAIN, 9, Ui.UNITS_pt);
        setFont(appFont);
        } catch (ClassNotFoundException e) {
        }
        add(new LabelField(message));
        add(new SeparatorField());
        okButton = new cusButtField("OK", Color.WHITE, Color.LIGHTGREY, Color.YELLOW, Color.GREEN,Field.FIELD_HCENTER);
        okButton.setChangeListener(this);
        add(okButton);
        }

    protected void sublayout(int width, int height) {
        layoutDelegate(width - 80, height - 80);
        setPositionDelegate(10, 10);
        setExtent(width - 60, Math.min(height - 60, getDelegate().getHeight() + 20));
        setPosition(30, (height - getHeight())/2);
        }

    public void fieldChanged(Field field, int context) {
        if (field == okButton) {
        close();
        }
        }


}

yet the "paintBackground" part above doesn't work, i.e. dialog appears on a white background. What do you think might be wrong, should I somehow call this method? Should I put in some other place?

Thanks!

Roger
  • 6,443
  • 20
  • 61
  • 88

1 Answers1

2

I had the same problem a while ago on JDE 4.5. As explained here (Blackberry-KB), the code below worked for me.

public void paint(Graphics graphics)
{
    graphics.setBackgroundColor(Color.DARKRED);
    graphics.clear();
    super.paint(graphics);
}

also, you may want to check this question.

Community
  • 1
  • 1
denolk
  • 765
  • 14
  • 27