我想制作一个由LabelField和Textbox组成的自定义控件。 如何使用jde作为黑莓的IDE进行自定义控件。
提前致谢。
答案 0 :(得分:0)
在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