Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
TA2_SWT
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
Service Desk
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
Nick-Luis Achtmann
TA2_SWT
Commits
e80bf0d4
Commit
e80bf0d4
authored
2 months ago
by
Timon Harries
Browse files
Options
Downloads
Plain Diff
Merge branch 'dev' of gitlab.uni-hannover.de:nick130625/ta2_swt into dev
parents
ca6339f8
1c5e0995
No related branches found
No related tags found
1 merge request
!1
Verision 1.0 finished
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/Scene.fxml
+10
-10
10 additions, 10 deletions
src/Scene.fxml
src/SceneController.java
+21
-5
21 additions, 5 deletions
src/SceneController.java
src/TicTacToe.java
+1
-0
1 addition, 0 deletions
src/TicTacToe.java
with
32 additions
and
15 deletions
src/Scene.fxml
+
10
−
10
View file @
e80bf0d4
...
...
@@ -15,7 +15,7 @@
</Label>
</children>
</AnchorPane>
<GridPane
gridLinesVisible=
"true"
layoutX=
"67.0"
layoutY=
"85.0"
prefHeight=
"313.0"
prefWidth=
"313.0"
>
<GridPane
fx:id=
"gridPane"
gridLinesVisible=
"true"
layoutX=
"67.0"
layoutY=
"85.0"
prefHeight=
"313.0"
prefWidth=
"313.0"
>
<columnConstraints>
<ColumnConstraints
hgrow=
"SOMETIMES"
minWidth=
"10.0"
prefWidth=
"100.0"
/>
<ColumnConstraints
hgrow=
"SOMETIMES"
minWidth=
"10.0"
prefWidth=
"100.0"
/>
...
...
@@ -27,15 +27,15 @@
<RowConstraints
minHeight=
"10.0"
prefHeight=
"30.0"
vgrow=
"SOMETIMES"
/>
</rowConstraints>
<children>
<Button
mnemonicParsing=
"false"
onAction=
"#handleButtonClick"
prefHeight=
"133.0"
prefWidth=
"142.0"
GridPane.halignment=
"CENTER"
GridPane.valignment=
"CENTER"
/>
<Button
layoutX=
"10.0"
layoutY=
"10.0"
mnemonicParsing=
"false"
onAction=
"#handleButtonClick"
prefHeight=
"133.0"
prefWidth=
"142.0"
GridPane.columnIndex=
"
2
"
/>
<Button
layoutX=
"115.0"
layoutY=
"10.0"
mnemonicParsing=
"false"
onAction=
"#handleButtonClick"
prefHeight=
"133.0"
prefWidth=
"142.0"
GridPane.columnIndex=
"
1
"
/>
<Button
layoutX=
"10.0"
layoutY=
"10.0"
mnemonicParsing=
"false"
onAction=
"#handleButtonClick"
prefHeight=
"133.0"
prefWidth=
"142.0"
GridPane.rowIndex=
"
1
"
/>
<Button
layoutX=
"10.0"
layoutY=
"10.0"
mnemonicParsing=
"false"
onAction=
"#handleButtonClick"
prefHeight=
"133.0"
prefWidth=
"142.0"
GridPane.columnIndex=
"1"
GridPane.rowIndex=
"1"
/>
<Button
layoutX=
"10.0"
layoutY=
"10.0"
mnemonicParsing=
"false"
onAction=
"#handleButtonClick"
prefHeight=
"133.0"
prefWidth=
"142.0"
GridPane.columnIndex=
"
2
"
GridPane.rowIndex=
"
1
"
/>
<Button
layoutX=
"10.0"
layoutY=
"10.0"
mnemonicParsing=
"false"
onAction=
"#handleButtonClick"
prefHeight=
"133.0"
prefWidth=
"142.0"
GridPane.rowIndex=
"
2
"
/>
<Button
layoutX=
"10.0"
layoutY=
"10.0"
mnemonicParsing=
"false"
onAction=
"#handleButtonClick"
prefHeight=
"133.0"
prefWidth=
"142.0"
GridPane.columnIndex=
"
1
"
GridPane.rowIndex=
"
2
"
/>
<Button
layoutX=
"10.0"
layoutY=
"10.0"
mnemonicParsing=
"false"
onAction=
"#handleButtonClick"
prefHeight=
"133.0"
prefWidth=
"142.0"
GridPane.columnIndex=
"2"
GridPane.rowIndex=
"2"
/>
<Button
fx:id=
"button1"
text=
" "
mnemonicParsing=
"false"
onAction=
"#handleButtonClick"
prefHeight=
"133.0"
prefWidth=
"142.0"
GridPane.halignment=
"CENTER"
GridPane.valignment=
"CENTER"
GridPane.columnIndex=
"0"
GridPane.rowIndex=
"0"
/>
<Button
fx:id=
"button2"
text=
" "
layoutX=
"10.0"
layoutY=
"10.0"
mnemonicParsing=
"false"
onAction=
"#handleButtonClick"
prefHeight=
"133.0"
prefWidth=
"142.0"
GridPane.columnIndex=
"
0
"
GridPane.rowIndex=
"1"
/>
<Button
fx:id=
"button3"
text=
" "
layoutX=
"115.0"
layoutY=
"10.0"
mnemonicParsing=
"false"
onAction=
"#handleButtonClick"
prefHeight=
"133.0"
prefWidth=
"142.0"
GridPane.columnIndex=
"
0
"
GridPane.rowIndex=
"2"
/>
<Button
fx:id=
"button4"
text=
" "
layoutX=
"10.0"
layoutY=
"10.0"
mnemonicParsing=
"false"
onAction=
"#handleButtonClick"
prefHeight=
"133.0"
prefWidth=
"142.0"
GridPane.columnIndex=
"1"
GridPane.rowIndex=
"
0
"
/>
<Button
fx:id=
"button5"
text=
" "
layoutX=
"10.0"
layoutY=
"10.0"
mnemonicParsing=
"false"
onAction=
"#handleButtonClick"
prefHeight=
"133.0"
prefWidth=
"142.0"
GridPane.columnIndex=
"1"
GridPane.rowIndex=
"1"
/>
<Button
fx:id=
"button6"
text=
" "
layoutX=
"10.0"
layoutY=
"10.0"
mnemonicParsing=
"false"
onAction=
"#handleButtonClick"
prefHeight=
"133.0"
prefWidth=
"142.0"
GridPane.columnIndex=
"
1
"
GridPane.rowIndex=
"
2
"
/>
<Button
fx:id=
"button7"
text=
" "
layoutX=
"10.0"
layoutY=
"10.0"
mnemonicParsing=
"false"
onAction=
"#handleButtonClick"
prefHeight=
"133.0"
prefWidth=
"142.0"
GridPane.columnIndex=
"2"
GridPane.rowIndex=
"
0
"
/>
<Button
fx:id=
"button8"
text=
" "
layoutX=
"10.0"
layoutY=
"10.0"
mnemonicParsing=
"false"
onAction=
"#handleButtonClick"
prefHeight=
"133.0"
prefWidth=
"142.0"
GridPane.columnIndex=
"
2
"
GridPane.rowIndex=
"
1
"
/>
<Button
fx:id=
"button9"
text=
" "
layoutX=
"10.0"
layoutY=
"10.0"
mnemonicParsing=
"false"
onAction=
"#handleButtonClick"
prefHeight=
"133.0"
prefWidth=
"142.0"
GridPane.columnIndex=
"2"
GridPane.rowIndex=
"2"
/>
</children>
</GridPane>
<Button
layoutX=
"446.0"
layoutY=
"170.0"
mnemonicParsing=
"false"
prefHeight=
"30.0"
prefWidth=
"82.0"
text=
"Restart"
/>
...
...
This diff is collapsed.
Click to expand it.
src/SceneController.java
+
21
−
5
View file @
e80bf0d4
import
javafx.fxml.FXML
;
import
javafx.scene.control.Button
;
import
javafx.event.ActionEvent
;
import
javafx.scene.layout.GridPane
;
import
logic.*
;
public
class
SceneController
{
...
...
@@ -14,15 +16,29 @@ public class SceneController {
}
@FXML
private
Button
myButton
;
private
GridPane
gridPane
;
@FXML
private
Button
button1
,
button2
,
button3
,
button4
,
button5
,
button6
,
button7
,
button8
,
button9
;
// Diese Funktion wird beim Button-Click aufgerufen
@FXML
private
void
handleButtonClick
()
{
private
void
handleButtonClick
(
ActionEvent
event
)
{
Button
pressedButton
=
(
Button
)
event
.
getSource
();
// Das gedrückte Button-Objekt wird extrahiert
String
buttonText
=
pressedButton
.
getText
();
// Der Text des gedrückten Buttons wird extrahiert
// Zugriff auf die Koordinaten des Buttons:
int
row
=
GridPane
.
getRowIndex
(
pressedButton
);
// Zeilen-Koordinate
int
col
=
GridPane
.
getColumnIndex
(
pressedButton
);
// Spalten-Koordinate
if
(
buttonText
.
equals
(
" "
))
{
// Setze X
pressedButton
.
setText
(
"X"
);
// TODO
player
.
makeMove
(
board
,
0
,
0
);
player
.
makeMove
(
board
,
col
,
row
);
}
System
.
out
.
println
(
"Button wurde geklickt!"
);
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/TicTacToe.java
+
1
−
0
View file @
e80bf0d4
...
...
@@ -20,6 +20,7 @@ public class TicTacToe extends Application {
@Override
public
void
start
(
Stage
primaryStage
)
throws
Exception
{
FXMLLoader
loader
=
new
FXMLLoader
(
getClass
().
getResource
(
"Scene.fxml"
));
loader
.
setController
(
new
SceneController
());
Parent
root
=
loader
.
load
();
// Controller-Instanz holen und initialisieren
...
...
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