无法访问FileChooser方法

时间:2019-11-30 09:00:50

标签: java intellij-idea javafx java-8

我无法访问FileChooser方法(当我尝试调用其中一种方法时,我的IntelliJ IDEA 2019.3抱怨找不到这些方法的符号)。奇怪的是,类本身可以很好地导入(我可以使FileChooser类型的对象成为可能),我试图将JDK从8u211更新为8u231,但这是行不通的……那么,如何解决这个问题?

package sample;

import calculus.LinearRegression;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.control.Alert;
import javafx.scene.control.Button;
import javafx.scene.control.TextField;
import javafx.stage.FileChooser;

import java.io.File;

public class Controller {
    @FXML private TextField x1,x2,x3,x4,x5,y1,y2,y3,y4,y5;
    @FXML private Button choseFile;

    FileChooser chooser = new FileChooser();
    chooser.getExtensionFilters(); //not works

    @FXML protected void calculateLinearRegression(ActionEvent actionEvent) {
        float[][] x = new float[5][2];
        float[] y = new float[5];
        x[0] = new float[]{Float.parseFloat(x1.getText()), 1};
        y[0] = Float.parseFloat(y1.getText());
        x[1] = new float[]{Float.parseFloat(x2.getText()), 1};
        y[1] = Float.parseFloat(y2.getText());
        x[2] = new float[]{Float.parseFloat(x3.getText()), 1};
        y[2] = Float.parseFloat(y3.getText());
        x[3] = new float[]{Float.parseFloat(x4.getText()), 1};
        y[3] = Float.parseFloat(y4.getText());
        x[4] = new float[]{Float.parseFloat(x5.getText()), 1};
        y[4] = Float.parseFloat(y5.getText());
        LinearRegression regression = new LinearRegression(x,y);
        Alert d = new Alert(Alert.AlertType.INFORMATION);
        d.setContentText("Approximated to y="+regression.result[0]+"x+"+regression.result[1]);
        d.showAndWait();
    }

    @FXML protected void openFileChooser(ActionEvent actionEvent){
            File file = chooser.showOpenDialog(((Button)actionEvent.getTarget()).getParent().getScene().getWindow());
        };
    }

0 个答案:

没有答案