Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
Mathdoku
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
tmp1u19
Mathdoku
Commits
8443e4d9
Commit
8443e4d9
authored
5 years ago
by
tmp1u19
Browse files
Options
Downloads
Patches
Plain Diff
Class that keeps the alerts, scenes that have to appear whwnever an action occurs.
parent
ec122b2c
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Window.java
+126
-0
126 additions, 0 deletions
Window.java
with
126 additions
and
0 deletions
Window.java
0 → 100644
+
126
−
0
View file @
8443e4d9
import
javafx.event.ActionEvent
;
import
javafx.event.EventHandler
;
import
javafx.geometry.Insets
;
import
javafx.geometry.Pos
;
import
javafx.scene.Scene
;
import
javafx.scene.control.*
;
import
javafx.scene.layout.VBox
;
import
javafx.scene.text.Font
;
import
javafx.stage.Modality
;
import
javafx.stage.Stage
;
import
javafx.stage.StageStyle
;
public
class
Window
{
public
void
showButtons
(
Cell
cell
,
int
n
)
{
VBox
menu
=
new
VBox
(
10
);
menu
.
setPadding
(
new
Insets
(
10
));
menu
.
setAlignment
(
Pos
.
TOP_LEFT
);
menu
.
setStyle
(
"-fx-background: rgb(201, 76, 76);"
);
Label
message
=
new
Label
(
"Which one will you choose?"
);
message
.
setFont
(
Font
.
font
(
20
));
menu
.
getChildren
().
add
(
message
);
ToggleGroup
toggle
=
new
ToggleGroup
();
for
(
int
i
=
0
;
i
<
n
;
i
++)
{
RadioButton
number
=
new
RadioButton
(
String
.
valueOf
(
i
+
1
));
number
.
setFont
(
Font
.
font
(
20
));
number
.
setToggleGroup
(
toggle
);
menu
.
getChildren
().
add
(
number
);
}
RadioButton
delete
=
new
RadioButton
(
"Delete"
);
delete
.
setFont
(
Font
.
font
(
20
));
delete
.
setToggleGroup
(
toggle
);
menu
.
getChildren
().
add
(
delete
);
Button
choice
=
new
Button
(
"Choose"
);
choice
.
setFont
(
Font
.
font
(
20
));
choice
.
setCancelButton
(
true
);
menu
.
getChildren
().
add
(
choice
);
Scene
scene
=
new
Scene
(
menu
);
Stage
inputButtons
=
new
Stage
();
choice
.
setOnAction
(
new
EventHandler
<
ActionEvent
>()
{
@Override
public
void
handle
(
ActionEvent
actionEvent
)
{
if
(
toggle
.
getSelectedToggle
()
!=
null
)
{
RadioButton
selectedRadioButton
=
(
RadioButton
)
toggle
.
getSelectedToggle
();
if
(
selectedRadioButton
.
equals
(
"Delete"
))
{
cell
.
getTextField
().
clear
();
}
else
{
cell
.
getTextField
().
setText
(
selectedRadioButton
.
getText
());
}
inputButtons
.
close
();
}
}
});
inputButtons
.
setScene
(
scene
);
inputButtons
.
initStyle
(
StageStyle
.
UTILITY
);
inputButtons
.
initModality
(
Modality
.
APPLICATION_MODAL
);
inputButtons
.
setTitle
(
"Button Control"
);
inputButtons
.
setMinWidth
(
300
);
inputButtons
.
setMinHeight
(
370
);
inputButtons
.
setX
(
400
);
inputButtons
.
setY
(
400
);
inputButtons
.
toFront
();
inputButtons
.
show
();
}
public
void
win
(
String
message1
,
String
message2
)
{
VBox
menu
=
new
VBox
(
5
);
menu
.
setAlignment
(
Pos
.
TOP_CENTER
);
menu
.
setStyle
(
"-fx-background: pink;"
);
Label
congrats
=
new
Label
(
message1
);
congrats
.
setFont
(
Font
.
font
(
35
));
Label
message
=
new
Label
(
message2
);
message
.
setFont
(
Font
.
font
(
25
));
menu
.
getChildren
().
addAll
(
congrats
,
message
);
Scene
scene
=
new
Scene
(
menu
);
Stage
winWindow
=
new
Stage
();
winWindow
.
setScene
(
scene
);
winWindow
.
initStyle
(
StageStyle
.
UTILITY
);
winWindow
.
initModality
(
Modality
.
APPLICATION_MODAL
);
winWindow
.
setTitle
(
"Game Won!"
);
winWindow
.
setMinHeight
(
150
);
winWindow
.
setMinWidth
(
400
);
winWindow
.
setX
(
800
);
winWindow
.
setY
(
500
);
winWindow
.
show
();
}
public
Alert
getAlertDialog
(
String
str
)
{
Alert
alert
=
new
Alert
(
Alert
.
AlertType
.
WARNING
,
str
,
ButtonType
.
YES
);
alert
.
setX
(
800
);
alert
.
setY
(
400
);
alert
.
setTitle
(
"Confirmation of Action"
);
//alert.setHeaderText("Are you sure you want to clear the board?");
//alert.setContentText("Be aware that all your data will be cleared.");
return
alert
;
}
}
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