Hi i am new to java, I am getting a error saying JavaFX controller method must have 0 or exactly 1 argument!!! it’s related to connecting javafx to GUI.
what did i do wrong? the error starts at
=> “@FXML
void executeCount(final ActionEvent event, String mode) {” <=
Here is the full code of controller:
package com.jbbwebsolutions.client;
import static com.redsolution.utility.GetURLContent.getData;
import java.net.URL;
import java.util.Arrays;
import java.util.ResourceBundle;
import com.mkyong.Data;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.control.RadioButton;
import javafx.scene.control.TextArea;
import javafx.scene.control.TextField;
import javafx.scene.control.ToggleGroup;
public class CounterController implements Initializable {
@FXML
private Button btnCount1;
@FXML
private RadioButton rbAll;
@FXML
private ToggleGroup toggleMode;
@FXML
private RadioButton rbEven;
@FXML
private RadioButton rbOdd;
@FXML
private TextField txtCountTo;
@FXML
private TextArea taCountTo;
@FXML
private Button btnCount2;
@FXML
void executeCount(final ActionEvent event, String mode) {
final String countTo = txtCountTo.getText();
mode = "all";
if (rbAll.isSelected()) {
mode = "all";
} else if (rbOdd.isSelected()) {
mode = "odd";
}
else if (rbEven.isSelected()) {
mode = "even";
}
final String sURL = "http://localhost:4567/counter/:mode/:goto"
.replace(":goto", countTo)
.replace(":mode", mode);
final Data data = getData(sURL, Data.class);
final String result = Arrays.toString(data.getData());
taCountTo.setText(result);
}
@Override
public void initialize(URL location, ResourceBundle resources) {
rbAll.setSelected(true);
}
}