Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
Inf2Pr_SoSe23_Gruppe03_UNO
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
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
Code review analytics
Issue analytics
Insights
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
Inf2Pr_SoSe23_Gruppe03_UNO
Inf2Pr_SoSe23_Gruppe03_UNO
Merge requests
!1
Der große Merge
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Der große Merge
Frontend-patch-73a8
into
master
Overview
1
Commits
11
Pipelines
0
Changes
1
Merged
Justin Klein
requested to merge
Frontend-patch-73a8
into
master
2 years ago
Overview
1
Commits
11
Pipelines
0
Changes
1
Expand
/UnoKarten/BackSide.png
/UnoKarten/Blau_Acht.png
/UnoKarten/Blau_Aussetzen.png
/UnoKarten/Blau_Drei.png
/UnoKarten/Blau_Eins.png
/UnoKarten/Blau_Neun.png
/UnoKarten/Blau_Richtungswechsel.png
/UnoKarten/Blau_Sechs.png
/UnoKarten/Blau_Zwei.png
/UnoKarten/Blau_Sieben.png
/UnoKarten/Blau_Fuenf.png
/UnoKarten/Blau_Null.png
/UnoKarten/Gelb_Drei.png
/UnoKarten/Gelb_Aussetzen.png
/UnoKarten/Gelb_Eins.png
/UnoKarten/Blau_Zwei_Ziehen.png
/UnoKarten/Blau_Vier.png
/UnoKarten/Gelb_Acht.png
/UnoKarten/Gelb_Neun.png
/UnoKarten/Gelb_Fuenf.png
/UnoKarten/Gelb_Richtungswechsel.png
/UnoKarten/Gelb_Sechs.png
/UnoKarten/Gelb_Sieben.png
/UnoKarten/Gelb_Null.png
/UnoKarten/Gelb_Zwei.png
/UnoKarten/Gelb_Vier.png
/UnoKarten/Gelb_Zwei_Ziehen.png
/UnoKarten/Gruen_Acht.png
/UnoKarten/Gruen_Eins.png
/UnoKarten/Gruen_Drei.png
/UnoKarten/Gruen_Aussetzen.png
/UnoKarten/Gruen_Fuenf.png
/UnoKarten/Gruen_Richtungswechsel.png
/UnoKarten/Gruen_Null.png
/UnoKarten/Gruen_Neun.png
/UnoKarten/Gruen_Sechs.png
/UnoKarten/Gruen_Sieben.png
/UnoKarten/Gruen_Vier.png
/UnoKarten/Gruen_Zwei.png
/UnoKarten/Gruen_Zwei_Ziehen.png
/UnoKarten/Rot_Acht.png
/UnoKarten/Rot_Aussetzen.png
/UnoKarten/Rot_Fuenf.png
/UnoKarten/Rot_Neun.png
/UnoKarten/Rot_Null.png
/UnoKarten/Rot_Eins.png
/UnoKarten/Rot_Drei.png
/UnoKarten/Rot_Richtungswechsel.png
/UnoKarten/Rot_Sieben.png
/UnoKarten/Rot_Vier.png
/UnoKarten/Wild_Draw_Four.png
/UnoKarten/Wild_Draw_Four_Gelb.png
/UnoKarten/Rot_Zwei_Ziehen.png
/UnoKarten/Rot_Sechs.png
/UnoKarten/Rot_Zwei.png
/UnoKarten/Wild_Draw_Four_Blau.png
/UnoKarten/Wild_Draw_Four_Gruen.png
/UnoKarten/Wild_Draw_Four_Rot.png
/UnoKarten/Wild_Multicolor.png
/UnoKarten/Wild_Multicolor_Blau.png
/UnoKarten/Wild_Multicolor_Gelb.png
/UnoKarten/Wild_Multicolor_Gruen.png
/UnoKarten/Wild_Multicolor_Rot.png
1
0
Merge request reports
Viewing commit
79941b50
Prev
Next
Show latest version
1 file
+
147
−
0
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
79941b50
Upload New File
· 79941b50
Justin Klein
authored
2 years ago
src/PlayerNamesInput.java
0 → 100644
+
147
−
0
Options
import
javax.swing.*
;
import
java.awt.*
;
import
java.awt.event.ActionEvent
;
import
java.awt.event.ActionListener
;
import
java.util.ArrayList
;
import
javax.swing.text.PlainDocument
;
import
javax.swing.text.AttributeSet
;
import
javax.swing.text.BadLocationException
;
public
class
PlayerNamesInput
extends
JFrame
{
private
JTextField
[]
nameFields
;
private
JCheckBox
[]
botCheckboxes
;
protected
ArrayList
<
String
>
Names
;
protected
ArrayList
<
Boolean
>
isBot
;
Object
locked1
=
null
;
public
PlayerNamesInput
(
Object
locked
)
{
locked1
=
locked
;
setTitle
(
"Spielernamen eingeben"
);
setDefaultCloseOperation
(
JFrame
.
EXIT_ON_CLOSE
);
setLayout
(
new
FlowLayout
());
JLabel
playerCountLabel
=
new
JLabel
(
"Anzahl der Spieler:"
);
add
(
playerCountLabel
);
SpinnerNumberModel
spinnerModel
=
new
SpinnerNumberModel
(
2
,
2
,
8
,
1
);
// Spieleranzahl zwischen 2 und 8
JSpinner
playerCountSpinner
=
new
JSpinner
(
spinnerModel
);
add
(
playerCountSpinner
);
JButton
playButton
=
new
JButton
(
"Play"
);
playButton
.
addActionListener
(
new
ActionListener
()
{
@Override
public
void
actionPerformed
(
ActionEvent
e
)
{
int
playerCount
=
(
int
)
playerCountSpinner
.
getValue
();
showPlayerNamesInput
(
playerCount
);
}
});
add
(
playButton
);
setSize
(
200
,
100
);
setLocationRelativeTo
(
null
);
setVisible
(
true
);
//Es wird ein fenster mit der größe 200 x 200 erstellt, indem man zwischen 2 und 8 Spielern auswählen kann
}
private
void
showPlayerNamesInput
(
int
playerCount
)
{
getContentPane
().
removeAll
();
setLayout
(
new
GridLayout
(
playerCount
+
1
,
3
));
JLabel
[]
labels
=
new
JLabel
[
playerCount
];
nameFields
=
new
JTextField
[
playerCount
];
botCheckboxes
=
new
JCheckBox
[
playerCount
];
for
(
int
i
=
0
;
i
<
playerCount
;
i
++)
{
labels
[
i
]
=
new
JLabel
(
"Spieler "
+
(
i
+
1
)
+
": "
);
nameFields
[
i
]
=
new
JTextField
(
10
);
int
maxLength
=
10
;
// Maximale Länge des Textfelds
nameFields
[
i
].
setDocument
(
new
PlainDocument
()
{
@Override
public
void
insertString
(
int
offset
,
String
str
,
AttributeSet
attr
)
throws
BadLocationException
{
if
(
str
==
null
)
return
;
if
((
getLength
()
+
str
.
length
())
<=
maxLength
)
{
super
.
insertString
(
offset
,
str
,
attr
);
}
}
});
botCheckboxes
[
i
]
=
new
JCheckBox
(
"Bot"
);
JPanel
panel
=
new
JPanel
(
new
FlowLayout
());
panel
.
add
(
labels
[
i
]);
panel
.
add
(
nameFields
[
i
]);
panel
.
add
(
botCheckboxes
[
i
]);
add
(
panel
);
}
JButton
submitButton
=
new
JButton
(
"Submit"
);
submitButton
.
addActionListener
(
new
ActionListener
()
{
@Override
public
void
actionPerformed
(
ActionEvent
e
)
{
Names
=
new
ArrayList
<
String
>();
isBot
=
new
ArrayList
<
Boolean
>();
for
(
int
i
=
0
;
i
<
playerCount
;
i
++)
{
Names
.
add
(
nameFields
[
i
].
getText
());
isBot
.
add
(
botCheckboxes
[
i
].
isSelected
());
}
//showPlayerNames(playerNames, isBot);
synchronized
(
locked1
)
{
locked1
.
notify
();
}
dispose
();
}
});
add
(
submitButton
);
setSize
(
800
,
800
);
revalidate
();
repaint
();
//Es wird ein fenster erstellt, mit der größe 800 x 800.
//In diesem Fenster befindet sich für jeden Spiler ein eingabe Feld für den jeweiligen Namen
//Zusätzlich gibt es ein Hacken. Damit lässt sich auswählen ob der "Spieler" eine Bot sein wird
}
private
void
showPlayerNames
(
String
[]
playerNames
,
boolean
[]
isBot
)
{
getContentPane
().
removeAll
();
setLayout
(
new
FlowLayout
());
JLabel
playerLabel
=
new
JLabel
(
"Spieler:"
);
add
(
playerLabel
);
for
(
int
i
=
0
;
i
<
playerNames
.
length
;
i
++)
{
JLabel
nameLabel
=
new
JLabel
(
playerNames
[
i
]
+
(
isBot
[
i
]
?
" (Bot)"
:
""
));
add
(
nameLabel
);
}
setSize
(
800
,
700
);
setLocationRelativeTo
(
null
);
setVisible
(
true
);
}
public
String
getNames
(
int
i
){
return
Names
.
get
(
i
);
}
public
int
getgroesse
(){
return
Names
.
size
();
}
public
ArrayList
<
Boolean
>
getisBot
(){
return
isBot
;
}
}
Loading