Merge branch 'Dev' of https://github.com/FUH22860/Graph into Dev
Well. F
This commit is contained in:
commit
25a59a1d57
@ -12,7 +12,7 @@ import javafx.scene.layout.GridPane;
|
|||||||
import javafx.stage.FileChooser;
|
import javafx.stage.FileChooser;
|
||||||
|
|
||||||
public class RootBorderPane extends BorderPane {
|
public class RootBorderPane extends BorderPane {
|
||||||
private Label title;
|
private Label title, data;
|
||||||
private TextField tfInput;
|
private TextField tfInput;
|
||||||
private Button btInput, btImport;
|
private Button btInput, btImport;
|
||||||
private GridPane gpInput;
|
private GridPane gpInput;
|
||||||
@ -29,6 +29,7 @@ public class RootBorderPane extends BorderPane {
|
|||||||
btInput = new Button("Absenden");
|
btInput = new Button("Absenden");
|
||||||
btImport = new Button("Importieren");
|
btImport = new Button("Importieren");
|
||||||
gpInput = new GridPane();
|
gpInput = new GridPane();
|
||||||
|
data = new Label();
|
||||||
|
|
||||||
tfInput.setPromptText("test");
|
tfInput.setPromptText("test");
|
||||||
}
|
}
|
||||||
@ -37,6 +38,7 @@ public class RootBorderPane extends BorderPane {
|
|||||||
gpInput.add(btInput, 0, 0);
|
gpInput.add(btInput, 0, 0);
|
||||||
gpInput.add(tfInput, 1, 0);
|
gpInput.add(tfInput, 1, 0);
|
||||||
gpInput.add(btImport, 2, 0);
|
gpInput.add(btImport, 2, 0);
|
||||||
|
gpInput.add(data, 1, 1);
|
||||||
|
|
||||||
setTop(title);
|
setTop(title);
|
||||||
setCenter(gpInput);
|
setCenter(gpInput);
|
||||||
@ -46,38 +48,25 @@ public class RootBorderPane extends BorderPane {
|
|||||||
btImport.setOnAction(event -> importCSV());
|
btImport.setOnAction(event -> importCSV());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void importCSV() {
|
private void importCSV() {
|
||||||
String fileName = "";
|
|
||||||
String filePath = "";
|
|
||||||
|
|
||||||
FileChooser fileChooser = new FileChooser();
|
FileChooser fileChooser = new FileChooser();
|
||||||
File selectedFile = fileChooser.showOpenDialog(null);
|
File selectedFile = fileChooser.showOpenDialog(null);
|
||||||
|
|
||||||
File readfile = selectedFile;
|
if(selectedFile.getName().endsWith(".csv")) {
|
||||||
if (readfile.exists()) {
|
|
||||||
fileName = readfile.getName();
|
|
||||||
filePath = readfile.getAbsolutePath();
|
|
||||||
} else {
|
|
||||||
System.out.println("The file does not exist.");
|
|
||||||
}
|
|
||||||
|
|
||||||
if(fileName.endsWith(".csv")) {
|
|
||||||
try {
|
try {
|
||||||
File file = selectedFile;
|
Scanner myReader = new Scanner(selectedFile);
|
||||||
Scanner myReader = new Scanner(file);
|
|
||||||
String data = "";
|
tfInput.setText(selectedFile.getAbsolutePath());
|
||||||
while (myReader.hasNextLine()) {
|
while (myReader.hasNextLine()) {
|
||||||
data += myReader.nextLine();
|
data.setText(myReader.nextLine());
|
||||||
}
|
}
|
||||||
System.out.println(data);
|
|
||||||
myReader.close();
|
myReader.close();
|
||||||
} catch (FileNotFoundException e) {
|
} catch (FileNotFoundException e) {
|
||||||
System.out.println("An error occurred.");
|
System.out.println("File not Found");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
System.out.println("The file is not a csv file.");
|
Main.showAlert("The file is not a csv file.");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user