我有一个自定义编辑字段
public class Custom_EditField extends EditField {
int width, row;
Custom_EditField(long style, int width, int row) {
super(style);
this.width = width;
this.row = row;
}
protected void layout(int width, int height) {
width = this.width;
height = this.row;
super.layout(width, Font.getDefault().getHeight() * row);
super.setExtent(width, Font.getDefault().getHeight() * row);
}
public int getPreferredHeight() {
return Font.getDefault().getHeight() * row;
}
public int getPreferredWidth() {
return width;
}
public void paint(Graphics graphics) {
super.paint(graphics);
graphics.setBackgroundColor(Color.GRAY);
graphics.clear();
graphics.setColor(Color.BLACK);
int labelWidth = getFont().getAdvance(getLabel());
graphics.drawRect(labelWidth, 0, getWidth() - labelWidth, getHeight());
graphics.drawText(this.getText(), 0, 0);
}
}
当我在编辑字段中键入一整行单词时,它会导致错误。似乎无法自动转到下一行。