Skip to content
Snippets Groups Projects
Commit 0efd731d authored by Abhay Menon's avatar Abhay Menon
Browse files

Merge branch 'viewfile' into 'main'

Added basic GUI to console application

See merge request !10
parents 140c062f e423c73b
No related branches found
No related tags found
2 merge requests!12Merge branch 'main' to 'viewfile',!10Added basic GUI to console application
Pipeline #84354 passed
...@@ -2,4 +2,7 @@ ...@@ -2,4 +2,7 @@
<project version="4"> <project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" /> <component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="17" project-jdk-type="JavaSDK" /> <component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="17" project-jdk-type="JavaSDK" />
<component name="SuppressKotlinCodeStyleNotification">
<option name="disableForAll" value="true" />
</component>
</project> </project>
\ No newline at end of file
...@@ -7,6 +7,7 @@ plugins { ...@@ -7,6 +7,7 @@ plugins {
id 'groovy-gradle-plugin' id 'groovy-gradle-plugin'
} }
repositories { repositories {
// Use the plugin portal to apply community plugins in convention plugins. // Use the plugin portal to apply community plugins in convention plugins.
gradlePluginPortal() gradlePluginPortal()
......
...@@ -4,6 +4,14 @@ ...@@ -4,6 +4,14 @@
plugins { plugins {
id 'notes.multi.kotlin-application-conventions' id 'notes.multi.kotlin-application-conventions'
id 'application'
id 'org.jetbrains.kotlin.jvm'
id 'org.openjfx.javafxplugin' version '0.0.13'
}
javafx {
version = '18.0.2'
modules = ['javafx.controls', 'javafx.graphics']
} }
dependencies { dependencies {
......
...@@ -5,10 +5,20 @@ package notes.multi.console ...@@ -5,10 +5,20 @@ package notes.multi.console
import notes.multi.utilities.Filemanager import notes.multi.utilities.Filemanager
import notes.multi.utilities.Note
import notes.multi.utilities.TextWindow
import javafx.application.Application
fun main() { fun main() {
// thesea re test functions feel free to use // thesea re test functions feel free to use
val f = Filemanager("${System.getProperty("user.dir")}/test/", "hello.txt") val n = Note()
f.writefile("hello world") val noteTitle = n.title
f.deletefile() val noteContent = n.text.toString()
println(f.openfile()) println(noteContent)
Application.launch(TextWindow()::class.java, "--title=${noteTitle}", "--text=${noteContent}")
// val f = Filemanager("${System.getProperty("user.dir")}/test/", "hello.txt")
// f.writefile("hello world")
// f.deletefile()
// println(f.openfile())
} }
...@@ -4,6 +4,14 @@ ...@@ -4,6 +4,14 @@
plugins { plugins {
id 'notes.multi.kotlin-library-conventions' id 'notes.multi.kotlin-library-conventions'
id 'application'
id 'org.jetbrains.kotlin.jvm'
id 'org.openjfx.javafxplugin' version '0.0.13'
}
javafx {
version = '18.0.2'
modules = ['javafx.controls', 'javafx.graphics']
} }
dependencies { dependencies {
......
package notes.multi.utilities
import javafx.application.Application
import javafx.stage.Stage
import javafx.scene.Scene
import javafx.scene.control.ScrollPane
import javafx.scene.control.TextArea
import javafx.scene.layout.VBox
import javafx.scene.layout.AnchorPane
import javafx.application.Application.Parameters
import javafx.scene.layout.Priority
class TextWindow(): Application() {
var paramsMap = mutableMapOf<String, String>()
override fun init() {
super.init()
val params = getParameters()
paramsMap = params.getNamed()
}
override fun start(stage: Stage) {
stage.setTitle(paramsMap["title"])
val textarea = TextArea()
textarea.setText(paramsMap["text"])
textarea.setWrapText(true)
val scroll = ScrollPane()
val anchor = AnchorPane(textarea)
AnchorPane.setTopAnchor(textarea, 0.0)
AnchorPane.setBottomAnchor(textarea, 0.0)
AnchorPane.setLeftAnchor(textarea, 0.0)
AnchorPane.setRightAnchor(textarea, 0.0)
scroll.setFitToHeight(true)
scroll.setHmin(300.0)
scroll.setFitToWidth(true)
// REMOVE THESE COMMENTS
// println("===========")
// println(scroll.isFitToHeight)
// println(scroll.isFitToWidth)
scroll.content = textarea
val box = VBox(anchor)
VBox.setVgrow(anchor, Priority.ALWAYS)
stage.scene = Scene(box, 300.0, 300.0)
stage.show()
}
}
\ No newline at end of file
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