FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
Source-Code-from-Tutorials/JavaFX/024_menus/Main.java at master · sofitech05/Source-Code-from-Tutorials · GitHub
sofitech05
/
Source-Code-from-Tutorials
Public
forked from
buckyroberts/Source-Code-from-Tutorials
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
Source-Code-from-Tutorials
/
JavaFX
/
024_menus
/
Main.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
81 lines (66 loc) · 2.75 KB
Breadcrumbs
Source-Code-from-Tutorials
/
JavaFX
/
024_menus
/
Main.java
Copy path
File metadata and controls
81 lines (66 loc) · 2.75 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import
javafx
.
application
.
Application
;
import
javafx
.
scene
.
Scene
;
import
javafx
.
scene
.
control
.*;
import
javafx
.
scene
.
layout
.
BorderPane
;
import
javafx
.
stage
.
Stage
;
public
class
Main
extends
Application
{
Stage
window
;
BorderPane
layout
;
public
static
void
main
(
String
[]
args
) {
launch
(
args
);
}
@
Override
public
void
start
(
Stage
primaryStage
)
throws
Exception
{
window
=
primaryStage
;
window
.
setTitle
(
"thenewboston"
);
//File menu
Menu
fileMenu
=
new
Menu
(
"File"
);
MenuItem
newFile
=
new
MenuItem
(
"New..."
);
newFile
.
setOnAction
(
e
->
System
.
out
.
println
(
"Create a new file..."
));
fileMenu
.
getItems
().
add
(
newFile
);
fileMenu
.
getItems
().
add
(
new
MenuItem
(
"Open..."
));
fileMenu
.
getItems
().
add
(
new
MenuItem
(
"Save..."
));
fileMenu
.
getItems
().
add
(
new
SeparatorMenuItem
());
fileMenu
.
getItems
().
add
(
new
MenuItem
(
"Settings..."
));
fileMenu
.
getItems
().
add
(
new
SeparatorMenuItem
());
fileMenu
.
getItems
().
add
(
new
MenuItem
(
"Exit..."
));
//Edit menu
Menu
editMenu
=
new
Menu
(
"_Edit"
);
editMenu
.
getItems
().
add
(
new
MenuItem
(
"Cut"
));
editMenu
.
getItems
().
add
(
new
MenuItem
(
"Copy"
));
MenuItem
paste
=
new
MenuItem
(
"Paste"
);
paste
.
setOnAction
(
e
->
System
.
out
.
println
(
"Pasting some crap"
));
paste
.
setDisable
(
true
);
editMenu
.
getItems
().
add
(
paste
);
//Help menu
Menu
helpMenu
=
new
Menu
(
"Help"
);
CheckMenuItem
showLines
=
new
CheckMenuItem
(
"Show Line Numbers"
);
showLines
.
setOnAction
(
e
-> {
if
(
showLines
.
isSelected
())
System
.
out
.
println
(
"Program will now display line numbers"
);
else
System
.
out
.
println
(
"Hiding line number"
);
});
CheckMenuItem
autoSave
=
new
CheckMenuItem
(
"Enable Autosave"
);
autoSave
.
setSelected
(
true
);
helpMenu
.
getItems
().
addAll
(
showLines
,
autoSave
);
//Difficulty RadioMenuItems
Menu
difficultyMenu
=
new
Menu
(
"Difficulty"
);
ToggleGroup
difficultyToggle
=
new
ToggleGroup
();
RadioMenuItem
easy
=
new
RadioMenuItem
(
"Easy"
);
RadioMenuItem
medium
=
new
RadioMenuItem
(
"Medium"
);
RadioMenuItem
hard
=
new
RadioMenuItem
(
"Hard"
);
easy
.
setToggleGroup
(
difficultyToggle
);
medium
.
setToggleGroup
(
difficultyToggle
);
hard
.
setToggleGroup
(
difficultyToggle
);
difficultyMenu
.
getItems
().
addAll
(
easy
,
medium
,
hard
);
//Main menu bar
MenuBar
menuBar
=
new
MenuBar
();
menuBar
.
getMenus
().
addAll
(
fileMenu
,
editMenu
,
helpMenu
,
difficultyMenu
);
layout
=
new
BorderPane
();
layout
.
setTop
(
menuBar
);
Scene
scene
=
new
Scene
(
layout
,
400
,
300
);
window
.
setScene
(
scene
);
window
.
show
();
}
}
Back
|
FazBrowse Home
|
New Git URL