开发者

BlackBerry - How to draw Custom Focusable Color/Style for a focusable field?

I have custom drawn fields which are focusable. Normally the default focus color is Blue which obviously doesn't match to every theme. So can you 开发者_开发技巧give me efficient or non efficient ideas to change the color of the focus? Thanks


Why don't you use skin or even custom drawing? Also remember to

  • check getVisualState() == VISUAL_STATE_FOCUS
  • remember to override and supress applyTheme method

alt text http://img515.imageshack.us/img515/4286/checkfocus.jpg

class FCheckBoxField extends CheckboxField {

    public FCheckBoxField(String label, boolean value) {
        super(label, value);
    }

    protected void paint(Graphics g) {
        if (getVisualState() == VISUAL_STATE_FOCUS) {
            int c = g.getColor();
            g.setColor(Color.CRIMSON);
            g.fillRect(0, 0, getWidth(), getHeight());
            g.setColor(c);
        }
        super.paint(g);
    }

    protected void applyTheme(Graphics arg0, boolean arg1) {
    }
}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜