package sample;
import java.net.URL;
import java.util.ResourceBundle;
import javafx.fxml.FXML;
import javafx.scene.control.MenuItem;
import javafx.scene.control.TextArea;
import javafx.stage.FileChooser;
import java.io.*;
public class Controller {
@FXML
private ResourceBundle resources;
@FXML
private URL location;
@FXML
private TextArea text_area_main;
@FXML
private MenuItem openfile_btn;
@FXML
private MenuItem savefile_btn;
@FXML
void initialize() {
assert text_area_main != null : "fx:id=\"text_area_main\" was not injected: check your FXML file 'sample.fxml'.";
assert openfile_btn != null : "fx:id=\"openfile_btn\" was not injected: check your FXML file 'sample.fxml'.";
assert savefile_btn != null : "fx:id=\"savefile_btn\" was not injected: check your FXML file 'sample.fxml'.";
openfile_btn.setOnAction(event -> {
});
String output = text_area_main.getText();
savefile_btn.setOnAction(event -> {
FileChooser f = new FileChooser();
File file = f.showSaveDialog(null);
try {
FileWriter writer = new FileWriter(file);
writer.write(output);
}catch(IOException eq){eq.printStackTrace();}
});
}
}
файл появляется при сохранении но он пустой