Skip to content
Snippets Groups Projects
Commit 8466d567 authored by Terence-ChanLY's avatar Terence-ChanLY
Browse files

Added SaveFile function

parent e644174d
No related branches found
No related tags found
No related merge requests found
Pipeline #84568 passed
......@@ -13,6 +13,7 @@ import javafx.stage.FileChooser
import javafx.stage.Stage
import java.io.File
import java.io.FileNotFoundException
import java.io.PrintWriter
import java.util.*
class Main : Application() {
......@@ -117,9 +118,9 @@ class Main : Application() {
val file = Menu("File")
val openFile = MenuItem("Open File")
val new = MenuItem("New")
val save = MenuItem("Save")
val saveFile = MenuItem("Save")
val exitApp = MenuItem("Exit")
file.items.addAll(openFile, new, save, exitApp)
file.items.addAll(openFile, new, saveFile, exitApp)
val edit = Menu("Edit")
val cut = MenuItem("Cut")
......@@ -158,6 +159,20 @@ class Main : Application() {
border.left = FolderView().build(selectedFile.parentFile.absolutePath)
}
//SaveFile function
saveFile.onAction = EventHandler {
val file = FileChooser().showSaveDialog(Stage());
if (file != null) {
try {
val printWriter = PrintWriter(file);
printWriter.write(text.text);
printWriter.close();
} catch (e: FileNotFoundException) {
e.printStackTrace();
}
}
}
border.top = topContainer
border.center = center
border.bottom = status
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment