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
07248f35
Commit
07248f35
authored
5 years ago
by
tmp1u19
Browse files
Options
Downloads
Patches
Plain Diff
Delete Mathdoku.java
parent
8443e4d9
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
Mathdoku.java
+0
-167
0 additions, 167 deletions
Mathdoku.java
with
0 additions
and
167 deletions
Mathdoku.java
deleted
100644 → 0
+
0
−
167
View file @
8443e4d9
import
javafx.application.Application
;
import
javafx.event.ActionEvent
;
import
javafx.event.EventHandler
;
import
javafx.geometry.Insets
;
import
javafx.geometry.Pos
;
import
javafx.scene.Scene
;
import
javafx.scene.control.Button
;
import
javafx.scene.control.TextField
;
import
javafx.scene.layout.*
;
import
javafx.scene.paint.Color
;
import
javafx.scene.shape.Rectangle
;
import
javafx.scene.text.Font
;
import
javafx.stage.Stage
;
import
javafx.scene.control.Label
;
public
class
Mathdoku
extends
Application
{
private
GridPane
grid
=
new
GridPane
();
private
VBox
menu
=
new
VBox
();
private
HBox
topButton
=
new
HBox
();
private
HBox
bottomButton
=
new
HBox
();
private
int
n
=
4
;
private
Cell
[][]
cells
;
private
int
[][]
values
;
public
static
void
main
(
String
[]
args
)
{
launch
(
args
);
}
@Override
public
void
start
(
Stage
primaryStage
)
{
menu
.
setPadding
(
new
Insets
(
10
));
menu
.
setAlignment
(
Pos
.
TOP_CENTER
);
topButton
.
setPadding
(
new
Insets
(
10
));
topButton
.
setAlignment
(
Pos
.
CENTER_LEFT
);
bottomButton
.
setPadding
((
new
Insets
(
10
)));
bottomButton
.
setAlignment
(
Pos
.
CENTER
);
grid
.
setAlignment
(
Pos
.
CENTER_LEFT
);
Button
undo
=
new
Button
(
"Undo"
);
Button
redo
=
new
Button
(
"Redo"
);
Button
help
=
new
Button
(
"Help"
);
Button
clear
=
new
Button
(
"Clear"
);
Button
fileLoad
=
new
Button
(
"File"
);
Button
textLoad
=
new
Button
(
"Text"
);
topButton
.
getChildren
().
addAll
(
undo
,
redo
,
help
,
clear
,
fileLoad
,
textLoad
);
//bottomButton.getChildren().addAll(clear, fileLoad, textLoad);
draw
();
retainValues
();
primaryStage
.
widthProperty
().
addListener
((
obs
,
oldVal
,
newVal
)
->
{
//menu.setPrefWidth((Double) newVal);
draw
();
drawInput
();
});
primaryStage
.
heightProperty
().
addListener
((
obs
,
oldVal
,
newVal
)
->
{
//menu.setPrefHeight((Double) newVal);
draw
();
drawInput
();
});
menu
.
getChildren
().
addAll
(
topButton
,
grid
);
Scene
scene
=
new
Scene
(
menu
);
primaryStage
.
setScene
(
scene
);
primaryStage
.
setMinWidth
(
700
);
primaryStage
.
setMinHeight
(
750
);
primaryStage
.
show
();
}
public
void
draw
()
{
cells
=
new
Cell
[
n
][
n
];
for
(
int
i
=
0
;
i
<
n
;
i
++)
{
for
(
int
j
=
0
;
j
<
n
;
j
++)
{
Cell
cell
=
new
Cell
(
""
);
cell
.
setTranslateX
(
j
*(
600
/
n
));
cell
.
setTranslateY
(
i
*(
600
/
n
));
cells
[
i
][
j
]
=
cell
;
grid
.
getChildren
().
add
(
cell
);
}
}
}
public
void
drawInput
()
{
for
(
int
i
=
0
;
i
<
n
;
i
++)
{
for
(
int
j
=
0
;
j
<
n
;
j
++)
{
if
(
values
[
i
][
j
]
!=
0
)
{
cells
[
i
][
j
].
setText
(
String
.
valueOf
(
values
[
i
][
j
]));
}
}
}
}
public
void
retainValues
()
{
values
=
new
int
[
n
][
n
];
for
(
int
i
=
0
;
i
<
n
;
i
++)
{
for
(
int
j
=
0
;
j
<
n
;
j
++)
{
int
finalI
=
i
;
int
finalJ
=
j
;
cells
[
i
][
j
].
getText
().
setOnAction
(
new
EventHandler
<
ActionEvent
>()
{
@Override
public
void
handle
(
ActionEvent
actionEvent
)
{
values
[
finalI
][
finalJ
]
=
Integer
.
parseInt
(
cells
[
finalI
][
finalJ
].
getText
().
getText
());
}
});
}
}
}
class
Cell
extends
StackPane
{
private
Label
label
;
private
TextField
text
;
public
Cell
(
String
label
)
{
this
.
label
=
new
Label
(
label
);
this
.
text
=
new
TextField
();
this
.
label
.
setFont
(
Font
.
font
(
20
));
//this.label.setAlignment(Pos.TOP_LEFT);
text
.
setPrefWidth
(
10
);
text
.
setFont
(
Font
.
font
(
35
));
text
.
setStyle
(
"-fx-text-box-border: transparent; -fx-background-color: transparent;"
);
text
.
setAlignment
(
Pos
.
CENTER
);
Rectangle
rectangle
=
new
Rectangle
(
600
/
n
,
600
/
n
);
rectangle
.
setFill
(
null
);
rectangle
.
setStroke
(
Color
.
BLACK
);
setPadding
(
new
Insets
(
40
));
getChildren
().
addAll
(
rectangle
,
this
.
text
,
this
.
label
);
}
public
String
getLabel
()
{
return
this
.
label
.
getText
();
}
public
TextField
getText
()
{
return
this
.
text
;
}
public
void
setText
(
String
text
)
{
this
.
text
.
setText
(
text
);
}
}
}
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