reading txt file javafx

Solutions on MaxInterview for reading txt file javafx by the best coders in the world

showing results for - "reading txt file javafx"
Maya
12 Feb 2016
1 package blah;
2 import javafx.application.Application;
3 import javafx.stage.Stage;
4 import javafx.stage.FileChooser;
5 import javafx.scene.Scene;
6 import javafx.scene.layout.VBox;
7 import javafx.scene.layout.HBox;
8 import javafx.scene.text.Text;
9 import javafx.scene.control.Button;
10 import javafx.event.ActionEvent;
11 import javafx.event.EventHandler;
12 import java.io.File;
13
14public class blah
15    extends Application {
16
17private Text actionStatus;
18private Stage savedStage;
19
20
21public static void main(String [] args) {
22
23    Application.launch(args);
24}
25
26@Override
27public void start(Stage primaryStage) {
28    Button open = new Button("open");
29    open.setOnAction(new SingleFcButtonListener());
30    HBox open1 = new HBox(10);
31    open1.getChildren().addAll(open);
32    Button save = new Button("Save");
33            HBox save1 = new HBox(10);
34            save1.getChildren().addAll(save);
35
36    actionStatus = new Text();
37
38
39
40    VBox vbox = new VBox(30);
41    vbox.getChildren().addAll( open1,save1,  actionStatus);
42    Scene scene = new Scene(vbox, 500, 300); 
43    primaryStage.setScene(scene);
44    primaryStage.show();
45    savedStage = primaryStage;
46}
47
48private class SingleFcButtonListener implements EventHandler<ActionEvent> {
49
50    @Override
51    public void handle(ActionEvent e) {
52
53        showSingleFileChooser();
54    }
55}
56
57private void showSingleFileChooser() {
58
59    FileChooser fileChooser = new FileChooser();
60    File selectedFile = fileChooser.showOpenDialog(null);
61
62    if (selectedFile != null) {
63
64        actionStatus.setText("File selected: " + selectedFile.getName());
65    }
66
67   }
68
69}
70
similar questions
queries leading to this page
reading txt file javafx