Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
FaultInOurPong
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Model registry
Operate
Environments
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
Group3
FaultInOurPong
Commits
2abe7f86
Commit
2abe7f86
authored
8 years ago
by
Arfa Butt
Browse files
Options
Downloads
Patches
Plain Diff
Updated View.java
parent
ec733e36
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Game_Code/src/View.java
+79
-29
79 additions, 29 deletions
Game_Code/src/View.java
with
79 additions
and
29 deletions
Game_Code/src/View.java
+
79
−
29
View file @
2abe7f86
...
...
@@ -17,29 +17,26 @@ public class View extends JFrame{
private
JButton
tutorial
=
new
JButton
(
"Tutorial"
);
private
JButton
exit
=
new
JButton
(
"Exit"
);
private
JButton
single
=
new
JButton
(
"Single Player Mode"
);
private
JButton
sObstacle
=
new
JButton
(
"Advanced Single Player Mode"
);
private
JButton
multi
=
new
JButton
(
"Multiplayer Mode"
);
JPanel
buttonPanel
=
new
JPanel
();
public
View
(){
super
(
"FaultInOurPong"
);
this
.
setSize
(
700
,
500
);
this
.
setResizable
(
false
);
JPanel
buttonPanel
=
new
JPanel
();
buttonPanel
.
setLayout
(
new
BoxLayout
(
buttonPanel
,
BoxLayout
.
Y_AXIS
));
load
.
setMaximumSize
(
start
.
getPreferredSize
());
highScores
.
setMaximumSize
(
start
.
getPreferredSize
());
tutorial
.
setMaximumSize
(
start
.
getPreferredSize
());
exit
.
setMaximumSize
(
start
.
getPreferredSize
());
start
.
setAlignmentY
(
CENTER_ALIGNMENT
);
start
.
setAlignmentX
(
CENTER_ALIGNMENT
);
load
.
setAlignmentY
(
CENTER_ALIGNMENT
);
load
.
setAlignmentX
(
CENTER_ALIGNMENT
);
highScores
.
setAlignmentY
(
CENTER_ALIGNMENT
);
highScores
.
setAlignmentX
(
CENTER_ALIGNMENT
);
tutorial
.
setAlignmentY
(
CENTER_ALIGNMENT
);
tutorial
.
setAlignmentX
(
CENTER_ALIGNMENT
);
exit
.
setAlignmentY
(
CENTER_ALIGNMENT
);
exit
.
setAlignmentX
(
CENTER_ALIGNMENT
);
buttonPanel
.
add
(
Box
.
createVerticalGlue
());
addButton
(
start
);
addButton
(
load
);
addButton
(
highScores
);
addButton
(
tutorial
);
addButton
(
exit
);
buttonPanel
.
add
(
Box
.
createVerticalGlue
());
start
.
addActionListener
(
new
ActionListener
()
{
public
void
actionPerformed
(
ActionEvent
e
)
{
...
...
@@ -47,17 +44,29 @@ public class View extends JFrame{
}
});
buttonPanel
.
add
(
Box
.
createVerticalGlue
());
buttonPanel
.
add
(
start
);
buttonPanel
.
add
(
Box
.
createVerticalStrut
(
20
));
buttonPanel
.
add
(
load
);
buttonPanel
.
add
(
Box
.
createVerticalStrut
(
20
));
buttonPanel
.
add
(
highScores
);
buttonPanel
.
add
(
Box
.
createVerticalStrut
(
20
));
buttonPanel
.
add
(
tutorial
);
buttonPanel
.
add
(
Box
.
createVerticalStrut
(
20
));
buttonPanel
.
add
(
exit
);
buttonPanel
.
add
(
Box
.
createVerticalGlue
());
load
.
addActionListener
(
new
ActionListener
()
{
public
void
actionPerformed
(
ActionEvent
e
)
{
load
();
}
});
highScores
.
addActionListener
(
new
ActionListener
()
{
public
void
actionPerformed
(
ActionEvent
e
)
{
highScores
();
}
});
tutorial
.
addActionListener
(
new
ActionListener
()
{
public
void
actionPerformed
(
ActionEvent
e
)
{
tutorial
();
}
});
exit
.
addActionListener
(
new
ActionListener
()
{
public
void
actionPerformed
(
ActionEvent
e
)
{
System
.
exit
(
0
);
}
});
add
(
buttonPanel
);
...
...
@@ -66,13 +75,54 @@ public class View extends JFrame{
this
.
setVisible
(
true
);
}
public
void
addButton
(
JButton
x
)
{
x
.
setMaximumSize
(
sObstacle
.
getPreferredSize
());
x
.
setAlignmentY
(
CENTER_ALIGNMENT
);
x
.
setAlignmentX
(
CENTER_ALIGNMENT
);
buttonPanel
.
add
(
x
);
buttonPanel
.
add
(
Box
.
createVerticalStrut
(
20
));
}
public
void
start
()
{
//getContentPane().removeAll();
//repaint();
buttonPanel
.
removeAll
();
this
.
getContentPane
().
removeAll
();
this
.
repaint
();
buttonPanel
.
setLayout
(
new
BoxLayout
(
buttonPanel
,
BoxLayout
.
Y_AXIS
));
buttonPanel
.
add
(
Box
.
createVerticalGlue
());
addButton
(
single
);
addButton
(
sObstacle
);
buttonPanel
.
add
(
Box
.
createVerticalGlue
());
add
(
buttonPanel
);
this
.
setVisible
(
true
);
single
.
addActionListener
(
new
ActionListener
()
{
public
void
actionPerformed
(
ActionEvent
e
)
{
single
();
}
});
}
public
void
single
()
{
Pong_viewAndController
view_controller
=
new
Pong_viewAndController
(
this
);
this
.
setVisible
(
false
);
}
public
void
load
()
{
}
public
void
highScores
()
{
}
public
void
tutorial
()
{
}
public
static
void
main
(
String
[]
args
)
{
View
menuPage
=
new
View
();
}
...
...
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