1
GridFane内にTextFieldを持っていて、ユーザータイプのコンテンツをInteger
に読み込んで複数の(非ダブル)計算に使用することができます。JavaFX TextFieldの内容を整数に変換する
TextField userInput = new TextField();
userInput.textProperty().addListener((ObservableValue<? extends String> observable, String oldValue, String newValue) -> {
if (!newValue.matches("\\d*")) {
userInput.setText(newValue.replaceAll("[^\\d]", ""));
}
});
sortButton.setOnMousePressed(e -> {
int savedValue = Integer.parseInt(userInput);
int outputMath = savedValue * 3;
int outputExpo = savedValue * 10;
int outputQuad = savedValue * 4;
});
リスナーは数字が、必ず何が受け入れられないます作るの偉大な仕事をしていませんが、これらの数字は、私が計算に使用することはできていないようだという文字列として読み込まれます。
問題の子は、Integer.parseInt(userInput)がここでそのトリックをしていないようです。何かアドバイス?この行で
ただし、Integer.valueOf()などの他の方法を試すこともできます。 – Elltz