我试图在TextArea
输入TextField
时立即将每个角色展示到public class Application_Controler {
@FXML
private TextField txt;
@FXML
private TextArea showTxt;
@FXML
void keyTyped(ActionEvent event) {
String text = txt.getText();
String oldText = showTxt.getText();
String nextText = oldText+text;
showTxt.setText(nextText);
}
}
。
我写了一些代码如下,但它不起作用:
Application_Controler.java
.fxml
以下是<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.*?>
<?import java.lang.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.layout.AnchorPane?>
<AnchorPane xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/8.0.40" fx:controller="imran.jfx.application.Application_Controler">
<children>
<AnchorPane layoutX="-17.0" layoutY="-14.0" prefHeight="461.0" prefWidth="454.0">
<children>
<TextField fx:id="txt" layoutX="122.0" layoutY="87.0" onKeyTyped="#keyTyped" prefHeight="55.0" prefWidth="229.0" />
<TextArea fx:id="showTxt" layoutX="56.0" layoutY="215.0" prefHeight="210.0" prefWidth="362.0" />
</children>
</AnchorPane>
</children>
</AnchorPane>
文件:
(define (random-number-list n lim)
(letrec ((maker
(lambda (n lim result)
(let loop ((g lim) (result '()))
(if (= g 0)
result
(loop (- lim 1) (cons (random lim) result)))))))
(maker n lim '())))
我该怎么做?
答案 0 :(得分:2)
您可以将$('html,body').animate({
scrollTop: $("#tab").offset().top
}, 1000)
绑定到textProperty() of TextField
。
textProperty() of TextArea
尝试在控制器的textArea.textProperty().bind(textField.textProperty());
内添加以下代码:
initialize()