0
フレームがあり、テキストフィールドを持つレイアウトはnaffですが、現時点では目的はありません。テキストフィールドのエントリに基づいて文字列のプロパティを更新します。
は、私は(.SET呼び出すことによって、コード自体の中に更新する
同様に(日食)テキストフィールドに入力されているものに基づいて、文字列プロパティを更新し、そしてそれはまた、以下のコンソールでプリントアウトしたいですここでは)
は私のコードです -
import javafx.application.Application;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.control.TextField;
import javafx.scene.layout.Pane;
import javafx.scene.text.Font;
public class TextEntry extends Application
{
private static StringProperty text =
new SimpleStringProperty("text");
public static void main(String [] args)
{
launch(args);
}
public void start(Stage primaryStage)
{
Pane root = new Pane();
TextField enterText = new TextField();
enterText.setFont(Font.font("SanSerif",20));
enterText.setOnMousePressed(e ->{
text.bind(enterText.textProperty());
System.out.println("the new value is: " + text);
});
root.getChildren().addAll(enterText);
Scene scene = new Scene(root,600,600);
primaryStage.setScene(scene);
primaryStage.setTitle("Text Entry");
primaryStage.show();
}
}
私は上記のコードの行を含むカップルの事を試してみました -
text.set("").bind(enterText.textProperty());
、任意のアイデア
と
text.textProperty().bind(enterText.textProperty());
の第二は、私が実現文法的に正しくないですが、私は解決策を考えることはできませんか?
すごい、ありがとう!それは私に少し迷惑をかけるようになっていた! – Treeno1