这是我的fxml区域
<TextArea fx:id="textArea" onKeyTyped="#handleTextAreaAction"
BorderPane.alignment="CENTER">
<BorderPane.margin>
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
</BorderPane.margin>
<padding>
<Insets bottom="1.0" left="1.0" right="1.0" top="1.0" />
</padding>
</TextArea>
这是我在控制器中的方法:
@FXML private TextArea textArea;
public void handleTextAreaAction(KeyEvent event)
{
textArea.setOnKeyPressed(new EventHandler<KeyEvent>() {
@Override
public void handle(KeyEvent event) {
System.out.println(event.getCode());
}
});
}
我想知道如何知道用户在文本区域中输入的每个字符的索引