views:

372

answers:

1

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

+1  A: 

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

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) {
    }
}
Max Gontar