Newer
Older
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package GUI.game;
import java.awt.BorderLayout;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.GridLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
public class View extends Window
{
private Controller controller;
private Model model;
public View(Controller game, Model gameModel)
this.model = gameModel;
this.controller = game;
this.setSize(controller.settings.size*46,controller.settings.size*26);
//w41 h26
this.setLayout(new GridLayout(controller.settings.size,controller.settings.size));
model.build();
for(int i=0;i<controller.settings.size;i++)
{
for(JButton actButton : model.squares[i])
{
this.add(actButton);
}
}
//Kulso panel
JPanel panel = new JPanel();
panel.setLayout(new GridBagLayout());
frame.setSize(controller.settings.size*46,(controller.settings.size+4)*26);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
GridBagConstraints c = new GridBagConstraints();
JPanel upper = new JPanel();
upper.setSize(controller.settings.size*41,100);
JLabel timeLeft = new JLabel();
JLabel points = new JLabel();
JButton stopButton = new JButton();
timeLeft.setText("asd");
points.setText("points");
stopButton.setText("buton");
timeLeft.setSize(1000, 100);
c.fill = GridBagConstraints.EAST;
c.gridx = 0;
c.gridy = 0;
upper.add(timeLeft);
upper.add(stopButton);
upper.add(points);
panel.add(upper,c);
JPanel buttons = new JPanel();
buttons.add(this);
c.fill = GridBagConstraints.HORIZONTAL;
c.gridx = 0;
c.gridy = 1;
panel.add(buttons,c);
frame.add(panel);