try this
import net.rim.device.api.system.Bitmap;
import net.rim.device.api.ui.Field;
import net.rim.device.api.ui.Graphics;
public class CustomButton extends Field {
final Bitmap bitmap1;
final Bitmap bitmap2;
Bitmap bitmap;
CustomButton() {
bitmap1 = Bitmap.getBitmapResource("button_01.jpg");
bitmap2 = Bitmap.getBitmapResource("button_02.jpg");
bitmap = bitmap1;
}
public int getPreferredHeight() {
return bitmap1.getHeight();
}
public int getPreferredWidth() {
return bitmap1.getWidth();
}
protected void paint(Graphics g) {
g.drawBitmap(0, 0, getWidth(), getHeight(), bitmap, 0, 0);
}
protected void fieldChangeNotify(int context) {
try {
getChangeListener().fieldChanged(this, context);
} catch (Exception exception) {
}
}
public boolean isFocusable() {
return true;
}
protected void layout(int width, int height) {
setExtent(Math.min(width, getPreferredWidth()), Math.min(height,
getPreferredHeight()));
}
protected void onFocus(int direction) {
bitmap = bitmap2;
invalidate();
}
protected boolean navigationClick(int status, int time) {
fieldChangeNotify(1);
return true;
}
protected void onUnfocus() {
bitmap = bitmap1;
invalidate();
}
}
and call like this
CustomButton button = new CustomButton(){
protected void fieldChangeNotify(int context) {
//button click
super.fieldChangeNotify(context);
}
};