Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

reading txt file javafx

 package blah;
 import javafx.application.Application;
 import javafx.stage.Stage;
 import javafx.stage.FileChooser;
 import javafx.scene.Scene;
 import javafx.scene.layout.VBox;
 import javafx.scene.layout.HBox;
 import javafx.scene.text.Text;
 import javafx.scene.control.Button;
 import javafx.event.ActionEvent;
 import javafx.event.EventHandler;
 import java.io.File;

public class blah
    extends Application {

private Text actionStatus;
private Stage savedStage;


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);

    actionStatus = new Text();



    VBox vbox = new VBox(30);
    vbox.getChildren().addAll( open1,save1,  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());
    }

   }

}
Comment

PREVIOUS NEXT
Code Example
Java :: Create dynamic tree view using JavaScript 
Java :: java 8 list of objects get only first occurance 
Java :: how does minus works in Java 
Java :: RecyclerView scrolled UP/DOWN listener 
Java :: constructors in java 
Java :: Java Floating-point Literals 
Java :: infinite loop in java 
Java :: java secureRandom certain range 
Java :: check if object is a string java 
Java :: Log exception details to string 
Java :: java unused import statement 
Java :: spigot give item 
Java :: Java Target annotations attributes 
Java :: search for a string in byte array 
Java :: android autocompletetextview hashmap 
Java :: 1 2 1 3 2 1 4 3 2 1 3 2 1 2 1 1 java 
Java :: get value from dynamic input android 
Java :: java vererbung methoden 
Java :: springboot endpoint body list 
Java :: venatana emergente con texto java 
Java :: reponse entity as result spring controller 
Java :: They say that they have to create an instance to their application. What does it mean? 
Java :: convert xml file to node tree with java 
Java :: Uri/beecrowd problem no 1118 solution in Java 
Java :: java try with multiple resources 
Java :: how to create a 2d arraylist java 
Java :: java to kotlin tutorial 
Java :: how to access methods from another class in java 
Java :: convert python code to java 
Java :: import class from package java 
ADD CONTENT
Topic
Content
Source link
Name
6+2 =