-1
私はjavafxの初心者です。ボタンをクリックして入力を保存できるフォームを作成しようとしています。しかし、それはエラーがあり、私は続行できません。javafx with Scene BuilderはtextFieldからgetTextを取得できません
public class InputDataController implements Initializable {
@FXML
private TextField Input;
@FXML
private void handleButtonAction(ActionEvent event) {
String t = Input->getText();
}
@Override
public void initialize(URL url, ResourceBundle rb) {
// TODO
}
}
はエラーが言う:
error: incompatible types: String is not a functional interface
String t = Input->getText();
私は別のものを実装しようとしてい
FXMLファイルで:InputDataController.javaで
<VBox prefHeight="300.0" prefWidth="400.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="ass.InputDataController">
<children>
<Label text=" Input" />
<TextField id="Input" fx:id="Input" onAction="#handleButtonAction" />
<Button fx:id="enter" onAction="#handleButtonAction" prefHeight="57.0" prefWidth="707.0" text="Enter" />
</children>
</VBox>
は、ここに私のコードです関数:
@FunctionalInterface
interface String {
String getText(TextField t);
}
しかし、それはまだと述べている:
error: cannot find symbol
は、この問題を解決するためのいずれかの方法がありますか?私が機能的なインタフェースを実装する必要がないなら、それは良いでしょう!