Sometimes we need to make a text field or label field with clickable function,
here’s some example gathered from several sources.

[0] overwrite the related methods

LabelField _testLink = new LabelField("Test", Field.FOCUSABLE | Field.USE_ALL_WIDTH) {
    protected boolean navigationClick(int status, int time) {
        System.out.println("Linked");
        return true;
    }
};

[1] href field

import net.rim.device.api.ui.Field;
import net.rim.device.api.ui.Font;
import net.rim.device.api.ui.FontFamily;
import net.rim.device.api.ui.Graphics;

public class HrefField extends Field {

private String content;
private Font fieldFont;
private int fieldWidth;
private int fieldHeight;
private boolean active = false;
private int backgroundColour = 0xffffff;
private int textColour = 0x333333;
private int maskColour = 0xBBBBBB;

public HrefField(String content) {
super(Field.FOCUSABLE);
this.content = content;
fieldFont = defaultFont();
fieldWidth = fieldFont.getAdvance(content)+2;
fieldHeight = fieldFont.getHeight() + 3;
}

public void setColours(int backgroundColour, int textColour, int maskColour) {
this.backgroundColour = backgroundColour;
this.textColour = textColour;
this.maskColour = maskColour;
invalidate();
}

public void setBackgroundColour(int backgroundColour){
this.backgroundColour = backgroundColour;
invalidate();
}

public void setTextColour(int textColour){
this.textColour = textColour;
invalidate();
}

public void setMaskColour(int maskColour){
this.maskColour = maskColour;
invalidate();
}

public void setFont(Font fieldFont){
this.fieldFont = fieldFont;
}

public int getPreferredWidth() {
return fieldWidth;
}

public int getPreferredHeight() {
return fieldHeight;
}

protected void layout(int arg0, int arg1) {
setExtent(getPreferredWidth(), getPreferredHeight());
}

protected void paint(Graphics graphics) {

if (active) {
graphics.setColor(maskColour);
graphics.fillRect(0, 0, fieldWidth, fieldHeight);
} else {
graphics.setColor(backgroundColour);
graphics.fillRect(0, 0, fieldWidth, fieldHeight);
}

graphics.setColor(textColour);
graphics.setFont(fieldFont);
graphics.drawText(content, 1, 1);
graphics.drawLine(1, fieldHeight-2, fieldWidth-2, fieldHeight-2);
}

protected boolean navigationClick(int status, int time) {
fieldChangeNotify(1);
return true;
}

protected void onFocus(int direction) {
active = true;
invalidate();
}

protected void onUnfocus() {
active = false;
invalidate();
}

public static Font defaultFont() {
try {
FontFamily theFam = FontFamily.forName("SYSTEM");
return theFam.getFont(net.rim.device.api.ui.Font.PLAIN, 14);
} catch (ClassNotFoundException ex) {
ex.printStackTrace();
}
return null;
}
}

[2] CustomButtonField

package com.thinkingblackberry;

import net.rim.device.api.ui.Field;
import net.rim.device.api.ui.Font;
import net.rim.device.api.ui.Graphics;
import net.rim.device.api.ui.Keypad;

public class CustomButtonField extends Field {
	private String label;
	private int textColorUnfocused;
	private int textColorFocused;
	private int backgroundColorUnfocused;
	private int backgroundColorFocused;

	private int horizontalPadding = 5;
	private int verticalPadding = 5;

	public CustomButtonField(String label, int textColorUnfocused,
			int textColorFocused, int backgroundColorUnfocused,
			int backgroundColorFocused, long style) {
		super(style);
		this.label = label;
		this.textColorUnfocused = textColorUnfocused;
		this.textColorFocused = textColorFocused;
		this.backgroundColorUnfocused = backgroundColorUnfocused;
		this.backgroundColorFocused = backgroundColorFocused;
	}

	protected void layout(int maxWidth, int maxHeight) {
		Font font = getFont();
		int width = font.getAdvance(label) + (horizontalPadding * 2);
		int height = font.getHeight() + (verticalPadding * 2);
		// Respect the maximum width and height available from our manager
		setExtent(Math.min(width, maxWidth), Math.min(height, maxHeight));
	}

	protected void paint(Graphics graphics) {
		// Draw background
		graphics.setColor(isFocus() ? backgroundColorFocused : backgroundColorUnfocused);
		graphics.fillRoundRect(0, 0, getWidth(), getHeight(), 10, 10);

		// Draw text
		graphics.setColor(isFocus() ? textColorFocused : textColorUnfocused);
		graphics.drawRoundRect(0, 0, getWidth(), getHeight(), 10, 10);
		int fontWidth = getFont().getAdvance(label);
		graphics.drawText(label, (getWidth()-fontWidth)/2, verticalPadding);
	}

	protected void drawFocus(Graphics graphics, boolean on) {
		// Don't draw the default focus
	}

	protected void onFocus(int direction) {
		super.onFocus(direction);
		invalidate();
	}

	protected void onUnfocus() {
		super.onUnfocus();
		invalidate();
	}

	public boolean isFocusable() {
		return true;
	}

	protected boolean navigationClick(int status, int time) {
		fieldChangeNotify(0);
		return true;
	}

	protected boolean keyChar(char character, int status, int time) {
		if (character == Keypad.KEY_ENTER) {
			fieldChangeNotify(0);
			return true;
		}
		return super.keyChar(character, status, time);
	}

	public String getLabel() {
		return label;
	}
}

[1] http://www.northcubed.com/site/?p=6
[2] http://www.thinkingblackberry.com/source/CustomButtonField.java