我想制作由 LabelField 和 Textbox 组成的自定义控件。我如何使用 jde 作为黑莓的 IDE 来制作自定义控件。
提前致谢。
在 Blackberry 中,您可以通过从 Field 扩展来创建自定义组件
public class MyField extends Field {
public void layout(int width, int height){
setExtent( width, height ); //set the field size
}
public void pain(Graphics g){
//do your own paint here
//g.drawText ("Test", 0, 0 );
}
}
如果您想创建由 LabelField 和 TextField 组成,我建议您从 TextField 扩展
public class InputField extends TextField {
private String _label;
private TextField _text;
public InputField(String label){
_label = label;
}
public void layout(int width, int height ){
setExtend( width + 200, height ); //just an example, i add 200 pixel for width
//you can get the width of the _label too
//need other functions to get width based on the String
}
//you override how to paint in screen
public void paint(Graphics g){
super.paint(g);
g.drawText (getLeft()-200, getTop(), _label);
}
}
在此处查看更多示例 http://supportforums.blackberry.com/t5/Java-Development/Custom-Control/td-p/159699