Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*FXMLDocumentController.java
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package chester;
- import java.net.URL;
- import java.io.File;
- import java.util.ResourceBundle;
- import javafx.event.ActionEvent;
- import javafx.fxml.FXML;
- import javafx.fxml.Initializable;
- import javafx.stage.FileChooser;
- import java.io.IOException;
- import javafx.scene.layout.BorderPane;
- import java.io.FileReader;
- import java.io.BufferedReader;
- import javafx.scene.control.TextArea;
- /**
- *
- * @author mohit
- */
- public class FXMLDocumentController implements Initializable {
- @FXML
- private BorderPane rootPane;
- private TextArea textArea;
- @FXML
- private void openFile(ActionEvent event) throws InterruptedException {
- FileChooser fc = new FileChooser();
- fc.setTitle("Open File");
- File file = fc.showOpenDialog(rootPane.getScene().getWindow());
- textArea = new TextArea("");
- try
- {
- System.out.println(file.getAbsolutePath());
- BufferedReader br = new BufferedReader(new FileReader(file));
- while((s=br.readLine())!=null)
- {
- System.out.println(s);
- textArea.appendText(s);
- }
- }
- catch(IOException e)
- {
- System.err.format("error", e);
- }
- }
- /*private void handleButtonAction(ActionEvent event) {
- System.out.println("You clicked me!");
- label.setText("Hello World!");
- }*/
- @Override
- public void initialize(URL url, ResourceBundle rb) {
- // TODO
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment