둥근 테두리가있는 사용자 지정 편집 필드를 만들었습니다. 그러나 커서는 CustomEditField
상단에 표시됩니다. 커서 위치를 필드의 가운데로 변경하는 방법. 이 문제에 대한 도움이 필요합니다. 다음 코드 스 니펫은 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);
}
스크린 샷이 매우 유용합니다. – mrvincenzo