02-09-2009 10:26 PM
Solved! Go to Solution.
02-09-2009 11:09 PM
02-09-2009 11:38 PM
02-10-2009 12:47 AM
02-10-2009 01:12 AM
Here is my code:
class MyChoiceField extends ObjectChoiceField{
MyChoiceField (String label, Object[] choices,long style,int choice){
super(label, choices,choice,style);
//this.setExtent(getContentWidth()+50, getHeight());
}
public void layout(int width, int height){
super.layout(width, height);
setExtent(getWidth() + 10, getPreferredHeight());
//setVirtualExtent(width, managerHeight);
}
public void paint(Graphics graphics){
graphics.setColor(Color.WHITE);
graphics.fillRect(0, 0, getWidth(), getHeight());
graphics.setColor(Color.BLACK);
int w = 10;
int h = w>>1;
for (int i=0; i<=h; i++) {
graphics.invert(i, i, w - (i << 1), 1);
//System.out.println(i + "~~~~ " + i + " " + i + " " + (w - (i << 1)) + " 1");
}
graphics.drawRect(1, 0, getWidth()-1, getHeight());
super.paint(graphics);
}
public void drawFocus(Graphics graphics,boolean on){
super.drawFocus(graphics, on);
}
but when the item is focused on , there is no change happen,not like the text or eles,help me.
02-10-2009 01:15 AM
02-10-2009 01:54 AM
class MyChoiceField extends ObjectChoiceField { boolean onFocuss; MyChoiceField (String label, Object[] choices,int choice,long style) { super(label, choices,choice,style); } public void paintBackground(Graphics graphics) { if(onFocuss) { graphics.clear(); int color = graphics.getColor(); graphics.setColor( 0x00FF00 ); } else { graphics.clear(); int color = graphics.getColor(); graphics.setColor( 0x000000 ); } } public void onFocus(int dir) { onFocuss = true; invalidate(); } public void onUnfocus() { onFocuss = false; invalidate(); } }