I have implemented fft for my school project(tuner), although, im not able to pass calculated frequency to GUI. I tried binding, keyframes, i just cant seem to get a grasp of it, im really new to java.
public class FrequencyBean {
double freq;
private SimpleDoubleProperty value = new SimpleDoubleProperty(this, "value");
public void setValue(double value){
this.value.set(value);
System.out.println(value+" set");
}
public DoubleProperty getDoublePropertyValue(){
System.out.println("gotvals");
return value;
}
public FrequencyBean(){
freq = 10.0;
}
that is part of my controller, also i got reccomended to use something called tight binding or so, which would be abstracting of this class. Is that good for my code?
This is my main controller:
public class Controller implements Initializable{
FrequencyBean fbean;
@FXML
private Label otherFq;
@FXML
private Text frequency;
@FXML
private Text sharpFq;
@FXML
private Rectangle sharp6;
@FXML
private Text flatFq;
@FXML
private Rectangle center_rectangle;
@FXML
private Rectangle sharp1;
@FXML
private Rectangle sharp2;
@FXML
private Rectangle sharp3;
@FXML
private Rectangle sharp4;
@FXML
private Rectangle sharp5;
@FXML
private Text centerFq;
@FXML
private Rectangle flat6;
@FXML
private Rectangle flat5;
@FXML
private Rectangle flat4;
@FXML
private Rectangle flat3;
@FXML
private Rectangle flat2;
@FXML
private Rectangle flat1;
@Override
public void initialize(URL location, ResourceBundle resources) {
fbean = new FrequencyBean();
otherFq = new Label();
frequency = new Text();
boolean stop = false;
InputThread input = new InputThread();
Task<Void> in = new Task<Void>() {
@Override
protected Void call() throws Exception {
input.run();
return null;
}
};
Thread th0 = new Thread(in);
th0.start();
frequency.textProperty().bind(fbean.getDoublePropertyValue());
}