我需要在我的代码中手动设置插入位置.有一个getCaretPosition()
下javafx.scene.control.TextInputControl
但没有setter方法.
如何设置插入位置?
Ser*_*nev 34
TextArea ta = new TextArea();
ta.setText("1234567890");
ta.positionCaret(4);
Run Code Online (Sandbox Code Playgroud)
小智 8
您可以使用前面提到的positionCaret函数.但请确保将其包装在Platform.runLater中.否则它可能根本不起作用.
Platform.runLater( new Runnable() {
@Override
public void run() {
textArea.positionCaret( 0 );
}
});
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
21751 次 |
最近记录: |