Skip to content
Snippets Groups Projects
Commit ec733e36 authored by Arfa Butt's avatar Arfa Butt
Browse files

Update Pong_viewAndController.java to work with View

parent 146ebd7b
No related branches found
No related tags found
No related merge requests found
import java.awt.*; import java.awt.*;
import javax.swing.*; import javax.swing.*;
public class Pong_viewAndController extends JFrame{ public class Pong_viewAndController extends JFrame{
private JButton start = new JButton("Start");
private JButton suspend = new JButton("Suspend"); private JButton suspend = new JButton("Suspend");
private JButton tutorial = new JButton("Tutorial"); private JButton resume = new JButton("Resume");
private JButton save = new JButton("Save"); private JButton save = new JButton("Save");
private JButton exit = new JButton("Exit"); private JButton exit = new JButton("Exit");
public Pong_viewAndController(JFrame frame){
public Pong_viewAndController(){
super("FaultInOurPong"); super("FaultInOurPong");
this.setSize(700,500); this.setSize(700,500);
this.setResizable(false); this.setResizable(false);
...@@ -20,16 +16,12 @@ public class Pong_viewAndController extends JFrame{ ...@@ -20,16 +16,12 @@ public class Pong_viewAndController extends JFrame{
JPanel buttonPanel = new JPanel(); JPanel buttonPanel = new JPanel();
buttonPanel.setLayout(new BoxLayout(buttonPanel,BoxLayout.Y_AXIS)); buttonPanel.setLayout(new BoxLayout(buttonPanel,BoxLayout.Y_AXIS));
start.setMaximumSize(suspend.getPreferredSize());
start.setAlignmentX(Component.CENTER_ALIGNMENT);
buttonPanel.add(start);
buttonPanel.add(Box.createVerticalStrut(10));
suspend.setAlignmentX(Component.CENTER_ALIGNMENT); suspend.setAlignmentX(Component.CENTER_ALIGNMENT);
buttonPanel.add(suspend); buttonPanel.add(suspend);
buttonPanel.add(Box.createVerticalStrut(10)); buttonPanel.add(Box.createVerticalStrut(10));
tutorial.setMaximumSize(suspend.getPreferredSize()); resume.setMaximumSize(suspend.getPreferredSize());
tutorial.setAlignmentX(Component.CENTER_ALIGNMENT); resume.setAlignmentX(Component.CENTER_ALIGNMENT);
buttonPanel.add(tutorial); buttonPanel.add(resume);
buttonPanel.add(Box.createVerticalStrut(10)); buttonPanel.add(Box.createVerticalStrut(10));
save.setMaximumSize(suspend.getPreferredSize()); save.setMaximumSize(suspend.getPreferredSize());
save.setAlignmentX(Component.CENTER_ALIGNMENT); save.setAlignmentX(Component.CENTER_ALIGNMENT);
...@@ -39,14 +31,10 @@ public class Pong_viewAndController extends JFrame{ ...@@ -39,14 +31,10 @@ public class Pong_viewAndController extends JFrame{
exit.setAlignmentX(Component.CENTER_ALIGNMENT); exit.setAlignmentX(Component.CENTER_ALIGNMENT);
buttonPanel.add(exit); buttonPanel.add(exit);
//JPanel west = new JPanel(new GridBagLayout());
// west.add(buttonPanel);
Game game = new Game(); Game game = new Game();
game_interface.add(buttonPanel); game_interface.add(buttonPanel);
game_interface.add(game); game_interface.add(game);
//add(west,BorderLayout.WEST);
add(game_interface); add(game_interface);
setLocationRelativeTo(null); setLocationRelativeTo(null);
...@@ -54,8 +42,8 @@ public class Pong_viewAndController extends JFrame{ ...@@ -54,8 +42,8 @@ public class Pong_viewAndController extends JFrame{
this.setVisible(true); this.setVisible(true);
} }
public static void main(String[] args){ /*public static void main(String[] args){
Pong_viewAndController view_controller = new Pong_viewAndController(); Pong_viewAndController view_controller = new Pong_viewAndController();
} }*/
} }
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment