Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
GameOfLife
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
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
sferi01
GameOfLife
Commits
72a7f5d0
Commit
72a7f5d0
authored
Dec 9, 2019
by
steyer
Browse files
Options
Downloads
Patches
Plain Diff
JMenu
parent
69544687
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/game/ExitListener.java
+18
-0
18 additions, 0 deletions
src/game/ExitListener.java
src/game/GameRunner.java
+1
-1
1 addition, 1 deletion
src/game/GameRunner.java
src/game/GameWindow.java
+34
-5
34 additions, 5 deletions
src/game/GameWindow.java
with
53 additions
and
6 deletions
src/game/ExitListener.java
0 → 100644
+
18
−
0
View file @
72a7f5d0
package
game
;
import
javax.swing.JFrame
;
import
java.awt.event.ActionEvent
;
import
java.awt.event.ActionListener
;
public
class
ExitListener
implements
ActionListener
{
JFrame
frame
;
public
ExitListener
(
JFrame
frame
)
{
this
.
frame
=
frame
;
}
public
void
actionPerformed
(
ActionEvent
e
)
{
frame
.
dispose
();
}
}
This diff is collapsed.
Click to expand it.
src/game/GameRunner.java
+
1
−
1
View file @
72a7f5d0
...
...
@@ -34,7 +34,7 @@ public class GameRunner extends Thread {
if
(
model
!=
null
)
model
.
fireTableDataChanged
();
try
{
sleep
(
5
0
0
);
sleep
(
3
50
);
}
catch
(
InterruptedException
e
)
{
e
.
printStackTrace
();
}
...
...
This diff is collapsed.
Click to expand it.
src/game/GameWindow.java
+
34
−
5
View file @
72a7f5d0
...
...
@@ -29,24 +29,48 @@ public class GameWindow extends JFrame {
JButton
stopButton
=
new
JButton
(
"Stop"
);
JButton
saveButton
=
new
JButton
(
"Save"
);
GameWindowButtonsListener
l
istener
=
new
GameWindowButtonsListener
(
model
);
GameWindowButtonsListener
buttonL
istener
=
new
GameWindowButtonsListener
(
model
);
startButton
.
setActionCommand
(
"start"
);
stopButton
.
setActionCommand
(
"stop"
);
saveButton
.
setActionCommand
(
"save"
);
startButton
.
addActionListener
(
l
istener
);
stopButton
.
addActionListener
(
l
istener
);
startButton
.
addActionListener
(
buttonL
istener
);
stopButton
.
addActionListener
(
buttonL
istener
);
saveButton
.
addActionListener
(
new
SaveButtonListener
(
this
));
bottomPanel
.
add
(
startButton
);
bottomPanel
.
add
(
stopButton
);
bottomPanel
.
add
(
saveButton
);
//TODO save
bottomPanel
.
add
(
saveButton
);
add
(
bottomPanel
,
BorderLayout
.
PAGE_END
);
JMenuItem
startItem
=
new
JMenuItem
(
"Indítás"
);
startItem
.
setActionCommand
(
"start"
);
JMenuItem
stopItem
=
new
JMenuItem
(
"Megállítás"
);
stopItem
.
setActionCommand
(
"stop"
);
startItem
.
addActionListener
(
buttonListener
);
stopItem
.
addActionListener
(
buttonListener
);
JMenuItem
saveItem
=
new
JMenuItem
(
"Mentés"
);
saveItem
.
addActionListener
(
new
SaveButtonListener
(
this
));
JMenuItem
speedItem
=
new
JMenuItem
(
"Sebesség"
);
//TODO befejezni
JMenuItem
exitItem
=
new
JMenuItem
(
"Bezárás"
);
exitItem
.
addActionListener
(
new
ExitListener
(
this
));
JMenu
menu
=
new
JMenu
(
"Menü"
);
menu
.
add
(
startItem
);
menu
.
add
(
stopItem
);
menu
.
addSeparator
();
menu
.
add
(
speedItem
);
menu
.
addSeparator
();
menu
.
add
(
exitItem
);
JMenuBar
menuBar
=
new
JMenuBar
();
menuBar
.
add
(
menu
);
setJMenuBar
(
menuBar
);
setVisible
(
true
);
pack
();
setResizable
(
false
);
setLocationRelativeTo
(
null
);
}
...
...
@@ -61,4 +85,9 @@ public class GameWindow extends JFrame {
model
.
saveToFile
(
fileChooser
.
getSelectedFile
());
}
}
public
void
dispose
(){
model
.
stop
();
super
.
dispose
();
}
}
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