丸い境界線を持つカスタム編集フィールドを作成しました。しかし、カーソルは の上部に表示されています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);
}