我创建了一个带有圆形边框的自定义编辑字段。但是光标显示在CustomEditField
. 如何将光标位置更改为字段中心。在这个问题上需要帮助。以下代码片段是CustomEditField
.
public CustomEditField() {
this(0);
setMaxSize(15);
setCursorPosition(AXIS_VERTICAL);
}
public CustomEditField(long style) {
this(new XYEdges(20, 10, 20, 10), Field.FIELD_HCENTER
| Field.USE_ALL_WIDTH | Field.NON_SPELLCHECKABLE
| TextField.NO_NEWLINE | CONSUME_INPUT | style);
}
public CustomEditField(String label, String initialValue) {
this(0);
setLabel(label);
setText(initialValue);
}
public CustomEditField(XYEdges points, long style) {
super(style);
setPadding(points);
}
/**
* Paints EditField Background with specified Format values
*/
protected void paintBackground(Graphics graphics) {
graphics.setColor(Color.WHITE);
graphics.fillRoundRect(10, getPaddingTop(), getWidth() - 10,
getHeight() - getPaddingBottom(), 20, 20);
graphics.setColor(0x686868);
graphics.drawRoundRect(10, getPaddingTop(), getWidth() - 10,
getHeight() - getPaddingBottom(), 20, 20);
graphics.setColor(Color.BLACK);
}