0

I've tried to write a graphic interface to my DataFrame project. I have to read DataFrame from file and then I want to count for example min for each column. I have an open button, so I can read a file, but I don't know how can I work on this file(if you know what I mean). When I tried to press min botton, there was a null pointer exception. I guess that the dataframe is empty. But what should I do to fix it? I also have to draw a graphs, but I totally do not know how to do it.

public class Graphics extends Application {
private Text actionStatus;
private Stage savedStage;
DataFrame d;
public static void main(String[] args) {
    Application.launch(args);
}

@Override
public void start(Stage primaryStage) {
    Button open = new Button("open");
    open.setOnAction(new SingleFcButtonListener());
    HBox open1 = new HBox(10);
    open1.getChildren().addAll(open);
    Button save = new Button("Save");
    HBox save1 = new HBox(10);
    save1.getChildren().addAll(save);
    Button min = new Button("Min");
    HBox min1 = new HBox(10);
    min1.getChildren().addAll(min);

    min.setOnAction(new SingleButtonListener());
    actionStatus = new Text();



    VBox vbox = new VBox(30);
    vbox.getChildren().addAll( open1,save1, min,  actionStatus);
    Scene scene = new Scene(vbox, 500, 300);
    primaryStage.setScene(scene);
    primaryStage.show();
    savedStage = primaryStage;

}
private class SingleFcButtonListener implements EventHandler<ActionEvent> {

    @Override
    public void handle(ActionEvent e) {
        showSingleFileChooser();

    }

}

private void showSingleFileChooser() {
    FileChooser fileChooser = new FileChooser();
    File selectedFile = fileChooser.showOpenDialog(null);

    if (selectedFile != null) {

        actionStatus.setText("File selected: " + selectedFile.getName());
        ArrayList<Class<? extends Value>> arr2 = new ArrayList<Class<? extends Value>>();
        arr2.add(Str.class);
        arr2.add(DateTime.class);
        arr2.add(com.projekt1.Double.class);
        arr2.add(Double.class);
        DataFrame d = new DataFrame(selectedFile.getName(), arr2, true);
        d.showDatabase();
    }

}
private class SingleButtonListener implements EventHandler<ActionEvent> {

    @Override
    public void handle(ActionEvent e) {
        showMean();

    }

}

private void showMean() {
    d.mindf().showDatabase();
    }

}
  • Problem may be this line `DataFrame d = new DataFrame(selectedFile.getName(), arr2, true);` you probably want to initialise the member variable as opposed to creating a local variable – Gnas Nov 19 '18 at 23:41
  • Is DataFrame a class you created ? if so can we have its body ? Can you also add you console output ? – Mohamed Benmahdjoub Nov 20 '18 at 08:27

0 Answers0