Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
CS346
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Simon Wang
CS346
Commits
e4188660
Commit
e4188660
authored
2 years ago
by
Terence-ChanLY
Browse files
Options
Downloads
Patches
Plain Diff
Added Open File function
parent
f1ab15ef
No related branches found
No related tags found
No related merge requests found
Pipeline
#84070
passed
2 years ago
Stage: build
Stage: test
Stage: deploy
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
application/src/main/kotlin/net/codebot/application/Main.kt
+25
-0
25 additions, 0 deletions
application/src/main/kotlin/net/codebot/application/Main.kt
with
25 additions
and
0 deletions
application/src/main/kotlin/net/codebot/application/Main.kt
+
25
−
0
View file @
e4188660
package
net.codebot.application
package
net.codebot.application
import
javafx.application.Application
import
javafx.application.Application
import
javafx.event.EventHandler
import
javafx.scene.Scene
import
javafx.scene.Scene
import
javafx.scene.control.*
import
javafx.scene.control.*
import
javafx.scene.layout.BorderPane
import
javafx.scene.layout.BorderPane
...
@@ -8,7 +9,11 @@ import javafx.scene.layout.HBox
...
@@ -8,7 +9,11 @@ import javafx.scene.layout.HBox
import
javafx.scene.layout.VBox
import
javafx.scene.layout.VBox
import
javafx.scene.text.Font
import
javafx.scene.text.Font
import
javafx.scene.text.Text
import
javafx.scene.text.Text
import
javafx.stage.FileChooser
import
javafx.stage.Stage
import
javafx.stage.Stage
import
java.io.File
import
java.io.FileNotFoundException
import
java.util.*
class
Main
:
Application
()
{
class
Main
:
Application
()
{
override
fun
start
(
stage
:
Stage
)
{
override
fun
start
(
stage
:
Stage
)
{
...
@@ -131,6 +136,26 @@ class Main : Application() {
...
@@ -131,6 +136,26 @@ class Main : Application() {
topContainer
.
getChildren
().
add
(
mainMenu
);
topContainer
.
getChildren
().
add
(
mainMenu
);
topContainer
.
getChildren
().
add
(
toolbar
);
topContainer
.
getChildren
().
add
(
toolbar
);
//OpenFile function
openFile
.
onAction
=
EventHandler
{
val
filechooser
=
FileChooser
();
val
file
=
File
(
"C:\\Users"
);
filechooser
.
setTitle
(
"Open my file"
);
filechooser
.
setInitialDirectory
(
file
);
val
selectedFile
=
filechooser
.
showOpenDialog
(
stage
);
try
{
val
scanner
=
Scanner
(
selectedFile
);
text
.
clear
()
while
(
scanner
.
hasNextLine
())
{
text
.
appendText
(
scanner
.
nextLine
()
+
"\n"
);
}
}
catch
(
e
:
FileNotFoundException
)
{
e
.
printStackTrace
();
}
}
border
.
top
=
topContainer
border
.
top
=
topContainer
border
.
center
=
center
border
.
center
=
center
border
.
bottom
=
status
border
.
bottom
=
status
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment