BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 12-01-2008, 07:01 AM   #1 (permalink)
Knows Where the Search Button Is
 
Join Date: Oct 2008
Model: 7100T
PIN: N/A
Carrier: Unknow
Posts: 42
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default Custom ButtonField doesnt paint

Please Login to Remove!

Ive override the paint method at my CustomButtonField, but it's never called.

Whats the problem?

Thanks.
Offline  
Old 12-01-2008, 10:20 AM   #2 (permalink)
Talking BlackBerry Encyclopedia
 
Join Date: Apr 2008
Location: Germany, BW
Model: -
PIN: N/A
Carrier: -
Posts: 310
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

my paint method is always called.
__________________
Blessed is the end user who expects nothing, for he/she will not be disappointed. (Franklin's Rule)
Offline  
Old 12-01-2008, 10:49 AM   #3 (permalink)
Knows Where the Search Button Is
 
Join Date: Oct 2008
Model: 7100T
PIN: N/A
Carrier: Unknow
Posts: 42
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Code:
public class EscaladosButton extends Field {

	private TarifaDTO tarifa;

	private Bitmap button;
	private Bitmap on;
	private Bitmap off;
	private int fieldHeight;



	public EscaladosButton(TarifaDTO tarifa) {		
		
		super(Manager.FOCUSABLE);
		on = Bitmap.getBitmapResource("escalados_icon.jpg");
		off = Bitmap.getBitmapResource("escalados_icon.jpg");
		fieldHeight = on.getHeight();
		this.tarifa = tarifa;
		button = off;	
		invalidate();		
	}

	public EscaladosButton() {
		super(Field.FOCUSABLE);

		button = off;

	}
	protected void onFocus(int arg0) {
		button = on;
		super.onFocus(arg0);
	}
	protected void onUnfocus() {
		button = off;
		super.onUnfocus();
	}
	
	protected void drawFocus(Graphics g, boolean arg1) {
		g.drawBitmap(0, 0, 0, fieldHeight, button, 0, 0);	
	}



	protected void paint(Graphics arg0) {
		arg0.drawBitmap(0, 0, 0, fieldHeight, button, 0, 0);
	}

	public TarifaDTO getTarifa() {
		return tarifa;
	}

	public void setTarifa(TarifaDTO tarifa) {
		this.tarifa = tarifa;
	}

	protected void layout(int arg0, int arg1) {
		// TODO Auto-generated method stub
		
	}

}
Here is my code.
Offline  
Old 12-01-2008, 11:04 AM   #4 (permalink)
BlackBerry Extraordinaire
 
Join Date: Mar 2008
Location: Austin, TX
Model: 9700
PIN: N/A
Carrier: T-Mobile
Posts: 1,644
Post Thanks: 0
Thanked 34 Times in 33 Posts
Default

Not a good idea to override layout() and then not implement it. remove this override or do a correct implementation, otherwise you extent will be 0,0.

Also, you should probably override isFocusable() and return true.
Offline  
Old 12-01-2008, 11:59 AM   #5 (permalink)
Knows Where the Search Button Is
 
Join Date: Oct 2008
Model: 7100T
PIN: N/A
Carrier: Unknow
Posts: 42
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by Dougsg38p View Post
Not a good idea to override layout() and then not implement it. remove this override or do a correct implementation, otherwise you extent will be 0,0.

Also, you should probably override isFocusable() and return true.
It's a request for extends Field class.

Thanks for your answer.
Offline  




Copyright 2004-2016 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.