Initial Commit
This commit is contained in:
commit
0f00467962
35
src/application/FileChooserExample.java
Normal file
35
src/application/FileChooserExample.java
Normal file
@ -0,0 +1,35 @@
|
||||
package application;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import javafx.application.Application;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.layout.BorderPane;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.layout.VBox;
|
||||
import javafx.stage.FileChooser;
|
||||
|
||||
public class FileChooserExample extends Application {
|
||||
public static void main(String[] args) {
|
||||
launch(args);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start(Stage primaryStage) {
|
||||
primaryStage.setTitle("JavaFX App");
|
||||
|
||||
FileChooser fileChooser = new FileChooser();
|
||||
|
||||
Button button = new Button("Select File");
|
||||
button.setOnAction(e -> {
|
||||
File selectedFile = fileChooser.showOpenDialog(primaryStage);
|
||||
});
|
||||
|
||||
VBox vBox = new VBox(button);
|
||||
Scene scene = new Scene(vBox, 960, 600);
|
||||
|
||||
primaryStage.setScene(scene);
|
||||
primaryStage.show();
|
||||
}
|
||||
}
|
46
src/application/Main.java
Normal file
46
src/application/Main.java
Normal file
@ -0,0 +1,46 @@
|
||||
package application;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import javafx.application.Application;
|
||||
import javafx.stage.FileChooser;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.control.Alert;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.Alert.AlertType;
|
||||
|
||||
public class Main extends Application {
|
||||
public static Button btImport;
|
||||
@Override
|
||||
public void start(Stage primaryStage) {
|
||||
try {
|
||||
RootBorderPane root = new RootBorderPane();
|
||||
Scene scene = new Scene(root,400,400);
|
||||
primaryStage.setAlwaysOnTop(true);
|
||||
primaryStage.setTitle("Rechner");
|
||||
primaryStage.setScene(scene);
|
||||
primaryStage.show();
|
||||
|
||||
FileChooser fileChooser = new FileChooser();
|
||||
|
||||
Button btImport = new Button("Select File");
|
||||
btImport.setOnAction(e -> {
|
||||
File selectedFile = fileChooser.showOpenDialog(primaryStage);
|
||||
});
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void showAlert(String message) {
|
||||
Alert alert = new Alert(AlertType.WARNING,message);
|
||||
alert.setHeaderText(null);
|
||||
alert.setTitle(null);
|
||||
alert.showAndWait();
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
launch(args);
|
||||
}
|
||||
}
|
59
src/application/RootBorderPane.java
Normal file
59
src/application/RootBorderPane.java
Normal file
@ -0,0 +1,59 @@
|
||||
package application;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.control.TextField;
|
||||
import javafx.scene.layout.BorderPane;
|
||||
import javafx.scene.layout.GridPane;
|
||||
import javafx.scene.layout.VBox;
|
||||
import javafx.stage.FileChooser;
|
||||
|
||||
public class RootBorderPane extends BorderPane {
|
||||
private Label title;
|
||||
private TextField tfInput;
|
||||
private Button btInput, btImport;
|
||||
private GridPane gpInput;
|
||||
|
||||
public RootBorderPane() {
|
||||
initComponents();
|
||||
addComponents();
|
||||
addHandler();
|
||||
}
|
||||
|
||||
private void initComponents() {
|
||||
title = new Label("Do stuff");
|
||||
tfInput = new TextField();
|
||||
btInput = new Button("Abesnden");
|
||||
btImport = new Button("Importieren");
|
||||
gpInput = new GridPane();
|
||||
|
||||
tfInput.setPromptText("test");
|
||||
}
|
||||
|
||||
private void addComponents() {
|
||||
gpInput.add(btInput, 0, 0);
|
||||
gpInput.add(tfInput, 1, 0);
|
||||
gpInput.add(btImport, 2, 0);
|
||||
|
||||
setTop(title);
|
||||
setCenter(gpInput);
|
||||
}
|
||||
|
||||
private void addHandler() {
|
||||
btImport.setOnAction(event -> importCSV());
|
||||
}
|
||||
|
||||
private void importCSV() {
|
||||
FileChooser fileChooser = new FileChooser();
|
||||
File selectedFile = fileChooser.showOpenDialog(null);
|
||||
|
||||
if (selectedFile != null) {
|
||||
|
||||
} else {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user